I've written an "abstraction layer" class for form parsing. There are many functions inside the class that create various elements of a form.
In these functions is the ability to define what the inputted values should be. If the inputted value does not match the specified pattern, it returns as false and adds the original inputted value to an array of false-inputs for calling that data if need be.
PHP Code:
protected function parseForm(){
$this->rRaw = array_merge($_POST, $_GET);
foreach($this->rRaw as $key => $value){
if(is_array($value)){
foreach($value as $validator => $content){
if(strpos($validator, 'formval_')){
if($this->validateForm(substr($validator, 9, -1), $content)){
if(strpos($validator, 'noclean_')){
$this->r[$key] = $content;
}else{
$this->r[$key] = $this->cleanData($content);
}
}else{
$this->r[$key] = false;
if(strpos($validator, 'noclean_')){
$this->r['false-inputs'][$key] = $content;
}else{
$this->r['false-inputs'][$key] = $this->cleanData($content);
}
}
}else{
$this->r[$key][$validator] = (strpos($validator, 'noclean_') ? $this->r[$key] = $content : $this->r[$key] = $this->cleanData($content));
}
}
}else{
$this->r[$key] = $this->cleanData($value);
}
}
$this->checkQueryString();
}
My problem is that when the user-inputted values do no pass the validation process line 14 of the above code is supposed to assign the variable as a boolean and set it to false.
The code works, besides this problem, for when I change it to assign it as a string 'false' it sets it so.
HOWEVER, when I'm setting it as a boolean it does NOT retain that value of false. It instead has no value.
I have tried specifically setting the variable as a boolean through settype(), but to no avail.
Again, wrapping that false value with quotes seems to make the variable retain its' value. Whereas without the quotes it does not retain its' value.