Re: Accessing $vars from within a class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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?

only if:
function hello() {
  global $sql;
  $sql = 'select * from table';
}

or

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

if it isn't global (or set any other global var) you cannot get the value...

(long name, to prevent confusions with other programs that use this
 function)

but it is not advised for anything

best regards

-- 
José Miguel Santibáñez
    jms@xxxxxxxxx


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get to your groups with one click. Know instantly when new email arrives
http://us.click.yahoo.com/.7bhrC/MGxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux