Jump to content

Assigning boolean values to non-objects display no errors?


eldan88

Recommended Posts

Hey guys. I am trying to assign a property in my class to a  true value. What I realized is that when I assign true to the property it doesn't display an error even when calling an object that does not exisit

 

 

for example this would be the correct calling of an object

$validator->delivery_method_session = true;

 

this is the incorrect calling of an object

 

$validatorrrrr ->delivery_method_session = truel

 

When assiging it true to an incorrect calling of an object it doesnt display any error message?? Does any might know why that happens?? Thanks!

Link to comment
Share on other sites

Huh? I am not following what you are saying.

 

That is not the "calling" of an object, that is the setting of a property for an object. Plus, you would normally use setter and getter methods for properties.

 

You can create new Objects and Properties on-the-fly - just like when you create a variable using something like:

$foo = 'bar';

You don't have to declare the object and property as you do in some languages. So, by using the wrong object name it is just creating a new object and setting that value to the property name.

 

Turn on error reporting in strict mode and you'll see a warning. Likewise if you were using a setter method you would see an error as well.

error_reporting(E_STRICT);

When using the above error reporting mode, this is the type of error you would receive

 

 

Strict Standards: Creating default object from empty value in C:\xampp\htdocs\test\test.php on line 18
Edited by Psycho
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.