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.

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

ob_ dynamic content
i was wondering about the potential to use ob to create a <div then remove it when the page

SAP Project Module
I have seen in the SAP Project Module,plan cost and budget are not equal and even difference is sign

browse folder only
hi,
is there a way i can browse or get the directory or folder only and not the file?
i just w

Socket Server
In my following socket server, I am trying to listen to a connection through port 12345 in my web br

Help with PHP Email Script
Hi guys,

I'm a newbie to php and need help with the script below:

At the moment when I

help removing unwanted graphic
How do I remove the small elongated rectangular shape between the "Latest post" and "

Sql and php order list script problems
Hi im having a few problems with trying to get the coding right on a orders list ive done (or trying

Help with file_get_html
The following code gives the expected results:

<html>
<head&g

remove innitial

and

tags
i am using tiny_mce as a text editor for my CMS.
buy now the problem is it add <p>

check how many commas the variable containing the query has between [i]select[/i
Hi...

iv made an sql table that contains id number - name of sql query and an sql query.
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