adam291086 Posted September 24, 2008 Share Posted September 24, 2008 Here is the function function get_template($domain,$account) { require_once('DbConnector.php'); $loginConnector = new DbConnector(); $getTemplate = $loginConnector->query("SELECT * FROM Site_Info WHERE Domain = '$domain' AND account_number='$account'"); $this->templatedata = $loginConnector->fetchArray($getTemplate); $temp = $this->templatedata['Id']; $getTemplate = $loginConnector->query("SELECT * FROM Template_Details WHERE Id = '$temp'"); $this->templatedata = $loginConnector->fetchArray($getTemplate); $image = $this->templatedata['example_location']; return $image; } the variable $image does contain the correct data. Now i am trying to echo out the returned variable like require_once ('../../code/cms.php'); $domain = $_SESSION['domain']; $account = $_SESSION['account_number']; $add = new cms(); $add ->get_template($domain,$account); $image = $add; echo $image; But instead of the image location i get Object written on the page. The function is within a class which is initated correctly. Quote Link to comment https://forums.phpfreaks.com/topic/125586-solved-echo-returned-variable-from-function/ Share on other sites More sharing options...
ranjuvs Posted September 24, 2008 Share Posted September 24, 2008 You have to do like this $image = $add ->get_template($domain,$account); echo $image; what you are doing is assigning the $add object to $image variable Quote Link to comment https://forums.phpfreaks.com/topic/125586-solved-echo-returned-variable-from-function/#findComment-649296 Share on other sites More sharing options...
adam291086 Posted September 24, 2008 Author Share Posted September 24, 2008 i knew it would be simple. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/125586-solved-echo-returned-variable-from-function/#findComment-649297 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.