Hi,

I came a cross some problems, which were caused by PHPTAS relying on the __toString() magic method, when converting objects to strings.


First problem: Exceptions can´t be thrown within __toString(), see:
<http://stackoverflow.com/questions/2429642/why-its-impossible-to-throw-exception-from-tostring>

Second problem: __toString() is not correctly implemented in PHP < 5.2.0, so that on a test server with an older PHP version, the output is just "Object".

Both problems are very easy to work around: The method __toString() has to be called explicitly instead of letting PHP do the magic work.

Here is, how I extended the phptal_tostring() and phptal_escape() functions to implement this workaround (3 small changes):

http://pastie.org/2022716

Is there a good reason not to include this kind of workaround into PHPTAL?

Regards
Manu



_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to