I was recently reading a few articles on PHP Object oriented programming and came across something like this:
class a {}
$temp = new a();
$temp->newfiled = 20; // This field is not present within the class
The above code works fine in PHP 5.3
Why dosent PHP throw an error? I am coming from Java background in which we can only use fields that have been defined within a class.
Update: Edited php.ini to error_reporting = E_ALL | E_STRICT, but it continues to hide errors.
Also, is this a feature of PHP?
In short: PHP is not Java. Slightly longer: PHP is dynamic type, whereas Java is a static typed language.
However, you could raise your error-level. You should see a notice, or (strict-)warning.
http://php.net/language.oop5.properties