PHP, OOPS! data typing Hi,
I've decided to move to OOP after my procedural coding background (for shame, I know!). I am now studying a PHP 5 OOP book but because it's not a very recent one (PHP 5 Objects, Patterns, and Practice - Apress) I've run into the problem of string types not being automatically recognised/converted when returning variables from a constructer within a class. The error I'm getting is:
'Object of class ClassName could not be converted to string'
Well, I know what the problem is, PHP will not do the typeing for you on variables as it once did. I've Googled endlessly for a solution but the fixes are often wrapped in long flame wars between those who agree with PHP's new treatment of variables and those who don't. This makes it difficult to get a solution. One solution I've seen is to use the __toString() function. This is not recognised by my version of PHP. Do I need to upgrade it or what? Does anyone have a simple method of converting the variables to their intended type or a best practice for returning the variables correctly?
cheers,
Mike |