Jump to content

Catchable fatal error: Object of class classname could not be converted to st


Jagand

Recommended Posts

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?

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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.