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
149 Like 26 Dislike
Previous forums Next forums
Other forums

Select question
Hi,

First I would like to say that php is pretty new for me..
so please don't shoot me if

how to get sn motherboard
Hello.
I want to get serial number motherboard, cpu and else hardware.
Can You show me sam

Seperate team from score
I am writing a site that does a NFL Pick 'em type application and I have a feed that gives me the sc

Convert .fdf to .pdf
I currently have a web form that uploads the form data to an .fdf file and emails it.

However

Error with login script
I am getting an error with my login script:

Error:
Code: Warning: Cannot modify header inf

Generate PDF
Hi guys,

I would like to know if there is a way to generate pdf when clicking on a link. In f

Breaking results into week blocks
I have a set of dates (and times), which are returned from a mySQL query.

These usually span

pspell
using pspell, is it possible to get words that would be best in the current phrase?

For examp

Problem in OnClientClick and OnClick sync
Hi,Strange and irritating problem: I have below button declaration in markup of the aspx page:

Script not running properly
Hello Everyone
This is a basic script for posting to a database. I'm not sure why it doesn't work

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