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

Image loading
Hi Developers,

I'm trying to display an image from images/image.gif getting the url from mysq

Using unserialize()
Hi there.

I have some data in my database that is serialized.

e.g.

a:2:{i:0

multiple recipients + dbuser mail recall
Hello,

I am building a php login script.

When the user registers the script will send

PHP5 - AJAX help
I've been following the tutorial on w2schools (http://www.w3schools.com/php/php_ajax_database.asp) a

problem with query error
First Thanks to those who helped me on my previous posts, and the following code i'm using is not mi

Printer configuration
Hi All,
Suppose one of the user deleted the printer settings unfortunatly ,then what is the pro

mysql UNION | warning mysql_fetch_array !!
Code: <?php
$i = 0;
$query1="SELECT * FROM `products` WHERE `div

Move array index to end
Hey guys,
Quick question:

I have an array that looks like this:
Code: [Select]$var =

[RESOLVED] Socket/Port remains open after app crashes
I'm having this problem with a networked app in vb.net.

If the program exits normally the por

Request-URI Too Large
I have created a simple submit form for a mysql database that puts a piece of code into database.<

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