AviNahum Posted August 28, 2009 Share Posted August 28, 2009 hey, i'm trying to convert this string <{page}> to this new $class $class = the class name to load... but i got this error: Catchable fatal error: Object of class home could not be converted to string in /var/www/lib/core_functions.php on line 141 this is the code im using public function load_template($class) { $class = new $class; $return = file_get_contents(LIBRARY_PATH."/template.txt"); $return = str_replace("<{page}>", $class, $return); echo $return; } any ideas? Thanks! Link to comment https://forums.phpfreaks.com/topic/172278-solved-convert-string-to-class/ Share on other sites More sharing options...
rhodesa Posted August 28, 2009 Share Posted August 28, 2009 Are you trying to replace <{page}> with the name of the class? As of right now, you are trying to replace it with an object, which can't just arbitrarily happen. Link to comment https://forums.phpfreaks.com/topic/172278-solved-convert-string-to-class/#findComment-908330 Share on other sites More sharing options...
AviNahum Posted August 28, 2009 Author Share Posted August 28, 2009 i trying to print content from txt file and replace the <{PAGE}> with a class call... any possible ideas? Link to comment https://forums.phpfreaks.com/topic/172278-solved-convert-string-to-class/#findComment-908337 Share on other sites More sharing options...
rhodesa Posted August 28, 2009 Share Posted August 28, 2009 So you figured this out? Link to comment https://forums.phpfreaks.com/topic/172278-solved-convert-string-to-class/#findComment-908456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.