stdClass and __set

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
droberts
Forum Newbie
Posts: 2
Joined: Wed Oct 13, 2010 10:38 am

stdClass and __set

Post by droberts »

Hello.

I have an object I created from class Post.

Code: Select all

$p = new Post();

get_class($p) 
will return the class Post.

After I assign a variable to the class using the magic method __set

Code: Select all

$p->datereceived = "1234";

Code: Select all

get_class($p)
will return stdClass.

Why did the class change?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: stdClass and __set

Post by AbraCadaver »

It shouldn't. There must be something else in your code.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: stdClass and __set

Post by John Cartwright »

AbraCadaver wrote:It shouldn't. There must be something else in your code.
In fact I just ran a quick test on 5.3.1, and did not experience the said behavior.
droberts
Forum Newbie
Posts: 2
Joined: Wed Oct 13, 2010 10:38 am

Re: stdClass and __set

Post by droberts »

I think this was happening because I was trying to pull an object out of an array by the wrong key.
Post Reply