Page 1 of 1
is there a strict mode in php?
Posted: Wed Feb 18, 2009 2:50 pm
by yacahuma
Is there some kind of strict mode in php that does not allow me to reference a non existen data member?
for example if I code something like
php does not complain. What exactly php doing? threating it as an array and creating the element dynamically?
for small programs, I dont care, but when code get BIG, little things like this are hard to find.
Re: is there a strict mode in php?
Posted: Wed Feb 18, 2009 3:05 pm
by Chris Corbyn
This bugs me too. I'm pretty sure that even with error reporting set to E_STRICT PHP does not complain. Try it though:
Code: Select all
<?php error_reporting(E_ALL | E_STRICT); ?>
Re: is there a strict mode in php?
Posted: Wed Feb 18, 2009 3:48 pm
by Benjamin
You are allowed to add new variables to classes externally and they will be public. You should use get and set methods if you require more control. Have a look at __get() and __set(), where you can add your own code to run checks on variables you are trying to set.
Re: is there a strict mode in php?
Posted: Wed Feb 18, 2009 5:05 pm
by yacahuma
chris
it works
Strict Standards: Creating default object from empty value in D:\Users\oky\htdocs\planillaplus\testm.php on line 10
astions:
I should be using set and get more often. I just always out of time.