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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.