Jagand Posted December 19, 2009 Share Posted December 19, 2009 Hi! I am getting the following error in my code: Catchable fatal error: Object of class classname could not be converted to string in "file name" on line ... My class definition: class classname { var $my_variable; function checkString($input) { $this->my_variable= preg_match("/name/",$input); return $this->my_variable; } } PHP code: $get_return = new classname; $get_return->checkString($input); print "$get_return <br/>"; Can someone help me? Link to comment https://forums.phpfreaks.com/topic/185691-catchable-fatal-error-object-of-class-classname-could-not-be-converted-to-st/ Share on other sites More sharing options...
rajivgonsalves Posted December 19, 2009 Share Posted December 19, 2009 your trying to print $get_return as your trying to convert a object to a string it will throw an errors you cannot convert an object to a string your code should be $get_return = new classname; echo $get_return->checkString($input); Link to comment https://forums.phpfreaks.com/topic/185691-catchable-fatal-error-object-of-class-classname-could-not-be-converted-to-st/#findComment-980510 Share on other sites More sharing options...
Jagand Posted December 19, 2009 Author Share Posted December 19, 2009 Thank you Rajiv Link to comment https://forums.phpfreaks.com/topic/185691-catchable-fatal-error-object-of-class-classname-could-not-be-converted-to-st/#findComment-980530 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.