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

Add "width" check when upload
Hi!

Can someone add a function that is checking if picture witdh is bigger then 800px whwn up

Using mysql_real_escape_string for displayed content
On my website users can input data into a textarea and it will store it in the mysql database. But,

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

Code error with Index.php
Error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/runevid/public_

Problems with adding a link to one position in a 'foreach' loop, please help
Hello!

Iam pretty new to programming and I wanna create a table with users from an array. It

Problems generating word documents on server side for security reasons
I have a problem with word documentation generation when generating a word document (docx) with PHP.

foreach result into a single variable
Hi,

I have this code...

Code: [Select]foreach ($_POST['Interests'] as $interest =&

Changes to hosting company's server has affected web contact form
I started a thread a couple of months ago about the contact forms on my client's website. Basically

Do While statement
hi guys,

This may sound trivial but im new to php and as part of an assignmenti have to const

need help about
i store the value of my select statement result to an array and stored it to a variable named $fname

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