Need help: how to catch acess of undefined class properties


Posted on 16th Feb 2014 07:03 pm by admin

Hello. I am learning OO with PHP and have hit a problem.
Some code runs as perfectly valid code, where i would like PHP to issue a warning / error.
I guess this is because of the loose typing of PHP, however this cause real bugs go unnoticed in my code and i am looking for a way to be able to detect this.

Did you know?Explore Trending and Topic pages for more stories like this.
The code sample does not produce any warning/error using "error_reporting=E_ALL" with php 5.2.10

Do anyone have a idea or suggestion?

Code: class Objekt
{
var $foo;
var $bar;
}

$x = new Objekt();
$x->foo = 4;
var_dump($x);

$x->baz = 9; //i would like this to cause an warning because "baz" is a undefined property of the Objekt class. but it dont and "baz" is added to the object
var_dump($x);
No comments posted yet

Your Answer:

Login to answer
149 Like 26 Dislike
Previous forums Next forums
Other forums

EU VAT Package 2010
Does any one know whether SAP will be developing new reporting functionality due the new VAT rules t

having a small php error tha deals with the 'foreach'
Last night i was working on a script for a cart and it seemed to working good, until this morning. F

MySQL-PHP Query Results Help
Hello all. I'm hoping to be able to get some help in solving a problem with query/rowcount output. I

How to ... (FAQs)
... get e-mail notifications As several people asked how to get e-mail notifications when new posti

Help? Need help on project with templates involving mysql and php.
I'm having a hard time explaining what I want but basically here is what I have in place:

-Da

javascript in php code causes page to display white
Hi All,

Odd one this, I've got the following code (below) which is a simple log in form. The

Serial number of exernal hard disk/Thumbdrive
Hi guys, I am new tio java networking concepts.Please tel me how to get Serial number of exernal

how to get values from $_Post with onchange="form.submit();"?
Hi, I have a form that submit to itself with a file upload field and two other hidden field values.<

"SEO" URLs
Hey, I'm wondering how to go about creating and using these types of URLs. I'm presuming it's PHP th

Securing a user input - need some confirmation
Hello All,

I am in the process of recoding a large proportion of an e-commerce site, one of t

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash