If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Boolean not holding value

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.

Can you show the code where you actually compare the true/false value?

Try with a strict comparison: ===

^ This
The problem is that PHP doesn't actually have a boolean, which is inherited from the C code which also doesn't have a boolean. Ultimately, boolean false is 0, and true is !0.
Fortunately, operations can use strict datatyping in PHP. Using identical operators (===) for individual comparisons, and using in_array with strict parameter checking (third parameter), are good options. Searching arrays can also be performed on strict checking. The identical check also performs a check on the zval type on top of the zval value (default is to check only the value).

You'll get to know the identical operator in PHP. Many functions especially string and array functions return false on failure. Since PHP arrays (and implicitly the strings since they are char arrays) are all 0 based, you need to use identical checking for false to see if it failed or not. Common operations for these are strpos and array_search.