GD77 Posted July 18, 2012 Share Posted July 18, 2012 any other method to access all variables inside pg() but not every var inside the class like $tst ? class Misc { public $t1,$t2,$tst; function pg() { $qry=mysql_query("..."); $fetch_pg=mysql_fetch_assoc($qry) ; $this->t1=$fetch_pg['...']; $this->t2=$fetch_pg['...']; foreach($this as $var => $value) { echo "$var: $value<br>"; } //return true; } }/*END class user_Related*/ $misc=new Misc(); echo $misc->pg(); Link to comment https://forums.phpfreaks.com/topic/265883-accessing-variables-with-in-a-functions-class/ Share on other sites More sharing options...
smoseley Posted July 18, 2012 Share Posted July 18, 2012 Inside a class, it's impossible for two functions to share eachother's scope. However, in 5.4, we're getting "bind", which will allow you to bind a scope to a closure. It won't do exactly what you want, but it may do what you need. Link to comment https://forums.phpfreaks.com/topic/265883-accessing-variables-with-in-a-functions-class/#findComment-1362372 Share on other sites More sharing options...
GD77 Posted July 18, 2012 Author Share Posted July 18, 2012 Thanks, than I ll drop it i ll find other way. Link to comment https://forums.phpfreaks.com/topic/265883-accessing-variables-with-in-a-functions-class/#findComment-1362374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.