MDanz Posted February 26, 2011 Share Posted February 26, 2011 i have two functions. In function two it has $id=9. how do i get function one to echo $id? how do i adjust the below example to accomplish this? $newdb = new Database(); class Database { function one() { $newdb->two(); echo $id; } function two() { $id = 9 return $id; } } Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted February 26, 2011 Share Posted February 26, 2011 function one() { $id = $this->two(); echo $id; } Quote Link to comment Share on other sites More sharing options...
MDanz Posted February 27, 2011 Author Share Posted February 27, 2011 i tried this and get this error.... Parse error: syntax error, unexpected T_RETURN in... <?php $newdb = new Database(); class Database { function one() { $id = $this->two(); echo $id; } function two() { $id = 9 return $id; } } ?> Quote Link to comment Share on other sites More sharing options...
MDanz Posted February 27, 2011 Author Share Posted February 27, 2011 now the page is blank <?php $newdb = new Database(); $newdb->one; class Database { function one() { $id = $this->two(); echo $id; } function two() { $id = 9; return $id; } } ?> Quote Link to comment 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.