Re: [PHP] Accessing to an Object from a function
Lorenzo Giuliani wrote: i made a script that uses an object to access to the site data, i divided the whole site into various high specialized functions. All functions accesses to a single object (the object is a txtSQL instance). ... but ... i can't access to the variable declared in the main script. This is something known as scope, and you really should know all about it: http://php.net/variables.scope In this particular case you can either user the $GLOBALS superglobal, or the global keyword. Both are covered on that manual page. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Accessing to an Object from a function
Stut wrote: Lorenzo Giuliani wrote: i made a script that uses an object to access to the site data, i divided the whole site into various high specialized functions. All functions accesses to a single object (the object is a txtSQL instance). ... but ... i can't access to the variable declared in the main script. This is something known as scope, and you really should know all about it: http://php.net/variables.scope In this particular case you can either user the $GLOBALS superglobal, or the global keyword. Both are covered on that manual page. or you pass in a reference/copy of the object as an argument to your function :-) -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php