Jump to content

accessing variables with in a function's Class


GD77

Recommended Posts

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

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.

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.