Forum Moderators: coopster

Message Too Old, No Replies

Accessing $vars from within a class

Urgent problem :s

         

asantos

12:01 am on Jun 5, 2006 (gmt 0)

10+ Year Member



Hi,

Im trying to get the $sql variable value from hello() in a()


function hello() {
$sql = 'select * from table';
}


class ABC {
function a() {
// How can I access hello()'s $sql?
}
}

Is there a way to do that? By referencing the variable or something like that?
Thanks, Andres

eelixduppy

12:29 am on Jun 5, 2006 (gmt 0)



Just take the variable out of the function and leave it at the top. Or, just put global [us2.php.net] before the variable declaration. Good luck!

coopster

2:27 pm on Jun 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Or you could perhaps return [php.net] the value.

asantos

3:49 pm on Jun 5, 2006 (gmt 0)

10+ Year Member



eelixduppy, thanks.
coopster, i cant, the function serves other processes with different needs.