Jump to content

echo $class->string; reserved/function names?


Marco000

Recommended Posts

First of apologies for any inconvenience if this has been posted before as I’m unsure of what it could possibly be called/come under besides something like "reserved variables"?

 

I have a class that pulls a result out of a database and loads them into class variables by the database field name like the following

 

// Load the results into the class
foreach ($array as $name => $value) {
$this->$name = $value;
}

 

This works fine as expected but the problem occurs when I try to echo one of the fields names in the database (it’s called "string") It ends up being like echo $advert->string; and it’s not outputting anything? In Dreamweaver its showing the class variable "string" as a different colour so I’m guessing something isn’t right in terms of "string" being reserved or a function?

 

How could I get the final/desired output/action I’m looking for here as I’m completely stumped! I normally Google for my solutions but have no idea what I have come across is called.

 

PS. Sorry for anything I do wrong, just signed up and don’t know the ropes yet in terms of acceptable behaviour, community expectations and ways to post queries.

But that means i might aswell change the field name in the database as it acomplishs the same thing?

 

also is there a list of reserved variable names? to look over to increase my knowledge of this? I notice this happens with "int" too (echo $object->int)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.