PHP - Concatenating objects and casting to string - bad idea?
Posted
by franko75
on Stack Overflow
See other posts from Stack Overflow
or by franko75
Published on 2010-04-10T11:04:09Z
Indexed on
2010/04/10
11:13 UTC
Read the original article
Hit count: 262
Is it bad practice to concatenate objects when used in this context:
$this->template->head .= new View('custom_javascript')
This is the way i normally add extra css/js stuff to specific pages. I use an MVC structure where my basic html template has a $head variable which I set in my main Website_controller. I have used this approach for a while as it means I can just add bits and pieces of css/js stuff from whichever page/controller needs it. But having come across a problem in PHP 5.1.6 where the above code results in "Object ID #24", the result of toString() not being called i think, I am rethinking whether i should just fix this to work in PHP 5.1.6 or if i should rethink this approach in general.
Any pointers appreciated!
© Stack Overflow or respective owner