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
186 Like 21 Dislike
Previous forums Next forums
Other forums

question about header() security
is is safe to just use the header() function to redirect someone if they are, say, not logged in? or

Text Not Displaying Correctly With PHP:GD
I recently moved servers and since then I have noticed that one line of text is showing weirdly.

what are '%S%', '%E%'
for example when i see Code: [Select]printf("Hello %srn", $name);
what does %s means

PL/SQL: ORA-00947: not enough values error message
Hi all i am getting Error(25,63): PL/SQL: ORA-00947: not enough values error message when executing

PHP url branch??
Functionally, using PHP, I'm doing a test of login input submitted by a user via an html form in a f

MII Trends - add data onto chart object
Hello,

Can anyone please provide some thoughts on my current requirement:
its pretty

Hotlinking Picasa as the image folder of a website
Hi there PHP freaks, I would like to create a private album in Picasa to use it as the image folder

BackButton Behaviour in AJAX
I have an ASPX Page AJAX Enabled!The page has a gridView and a DDL for filtering on it. The Gridview

creating a 1 to 100 in a table
hi guys I am a newb in php need some help.

I have a table with 1 column and 100 rows and in

Greek characters in php
Hi,

I'm making a script and I m using for first time greek characters.
I started to write

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