Class Variables PHP5

Carl on feb 24th 2011 06:23 am |

One nice quirck in PHP5:

If you write a class and use boolean variables in the class methods, you will need to initialise/declare it at the beginning of your method.

function methodenaam () {
$booleanvar = false;
...
}

If you ommit that, you will have the unexpected experience (in PHP5) that your variable will return ‘false’, even after you are 100% certain, it should be ‘true’. Anyway, it is a sign of good programming to declare/initialise your variables.

Filed in PHP @en

Comments are closed.