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
84 Like 30 Dislike
Previous forums Next forums
Other forums

add to sql result
ok see rite now my sites hit counter is counted from the mysql visitor log i need to clear it aft

$_GET problem
Hi all,

Have a bit of a problem with a little piece of code, I am not sure if this should be

Firewall / visited websites logger
Hi. I have a firewall implementation and I want to log all the websites visited on the machine. S

Login Issue's
Code: <?php
$file = fopen('user.txt', 'r');

/* Set login to false initially */

Generating unique numbers using php
Hi,
I need help in generating unique number using php.I tired using rand() in php.But, by using r

Question about the upload of large files
Hi there,

I have a question about the upload of large files, like videos (files generally abo

Run function every 5 mins ??
I have a function PostMessage()

How can I run it every 5 mins ??

array_diff weirdness
I'm using the following bit of code

$diff = array_diff($pids, $pidlist);
$diff = array_va

Trouble verifying database password
Thankyou to everyone who responded to my last post (I can't find the posting, it has been buried). <

Gaining access to Drop Down Menu Variable
code is below, I am creating a drop down menu. I want to echo the value selected in the drop down me

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