Re: Information

From: Date: Wed, 22 Jun 2011 20:12:57 +0000
Subject: Re: Information
References: 1  Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-11253@lists.php.net to get a copy of this message
On Wed, Jun 22, 2011 at 15:48, Donnell, Jason <Jason.Donnell@fmcti.com> wrote: > Hello, > > > > I recently resolved an issue that I was having with a server side > script.  It is a rather simple resolution, but can cause hours of > frustration and some additional comments added to the manual might be > extremely advantageous to other developers.  I apologize in advance if > the manual does state this, however I have triple checked the online PHP > manual and I cannot find any information on exactly what I am going to > describe. > > > > The manual does describe how to pass variables from JavaScript to PHP > server side script and to different PHP functions.  There is one > important short note that is worth mentioning - Variables obtained using > the $_Get method shall be passed to other functions by reference only. > My theory is that since the variable is linked to the URL, and we all > know that the URL is not changing unless you navigate to another page, > then the variable cannot change either which means it shall be passed by > reference only.  I have found, through experience that the variable > becomes "undefined" if it is passed by value to a function from the main > PHP script. > > > > Here is an example of what I am saying: > > > > $id = $_get['ID']; //obtained from JavaScript > > ..... > > Foo($id); //call function > > > > Function Foo($id) //invalid, id now is 'undefined' > > { > > } > > Function Foo(&$id) //valid > > { > > } Part of the problems you're experiencing - unless it's a mere typo - may be due to the fact that you've referenced both $_Get in speaking, and $_get in your code example. Unless you've defined this array yourself, it does not exist --- the PHP superglobal used for storing HTTP GET data is $_GET. It is cAsE-sEnSiTiVe, as are all variables. -- </Daniel P. Brown> Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/

« previous php.webmaster (#11253) next »