Information

From: Date: Wed, 22 Jun 2011 19:48:33 +0000
Subject: Information
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-11252@lists.php.net to get a copy of this message
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 { } If I should provide this information to a different email address, please let me know. Thanks, and have a great day! Jason Donnell Software Engineer E: jason.donnell@fmcti.com <mailto:jason.donnell@fmcti.com> | P: 814-898-5226 | F: 814-899-3414 FMC Technologies Measurement Solutions Inc. 1602 Wagner Ave. | Erie, PA 16510 | USA P: (814)898-5000 www.fmctechnologies.com/MeasurementSolutions <http://www.fmctechnologies.com/MeasurementSolutions>

« previous php.webmaster (#11252) next »