Re: put code into a function then the code dead,very strange.

From: Date: Tue, 02 Aug 2011 12:33:15 +0000
Subject: Re: put code into a function then the code dead,very strange.
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-314273@lists.php.net to get a copy of this message
On 2 August 2011 13:24, Sharl.Jimh.Tsin <amoiz.shine@gmail.com> wrote: > 在 2011-08-02二的 22:29 +1200,Simon J Welsh写道: > >> You're using $motoCols in your function, but have not defined it or passed it as an >> argument. >> --- >> Simon Welsh >> Admin of http://simon.geek.nz/ >> > > YES,thanks for taking me out.and i just have a question that the variety > $motoCols has been defined with the function "processJSONtoSQL" together > in the common.php which is imported into the main page at head. > > so WHY $motoCols can not be reachable by the function in one page? It is to do with variable scope. http://uk.php.net/manual/en/language.variables.scope.php / http://uk.php.net/manual/zh/language.variables.scope.php -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

« previous php.general (#314273) next »