View Single Post

  #21 (permalink)  
Old 03-30-2008
Gabest
 
Posts: n/a
Default Re: addslashes/mysql_real_escape_string

> mysql_real_escape_string() is not meant to be taking objects. It
> requires a string. If you want to do this, you need a __tostring()
> method in your class to convert to a string.
>
> Or, if you want to bring it back out into a string later, you should
> first serialize() the object, then after retrieval, unserialize() it.


This is not my class, SimpleXMLElement is an inbuilt class of php. You
can read an xml file into a variable and say "echo $xml->person-
>name", it will interpret it as a string and does not leak any memory.

If one function lets you rely on autocasting the other does not, then
php becomes a mine field for the programmer, or __tostring() can be
declared a broken idea.
Reply With Quote