RE: [PHP] _SERVER variable insd prnt sttmnt
For the sake of legibility you could always assign the contents of $_SERVER['PHP_SELF'] to another variable before using it in the print statement: $PHP_SELF = $_SERVER['PHP_SELF']; print ""; Shouldn't be a problem security-wise as long as register_globals is off; Even if somebody tried to pass an arbitrary value to PHP_SELF in the query string, it would only show up in $_GET['PHP_SELF']. It also provides a quick way to bring pre- 4.1.2 scripts relying on the old global $PHP_SELF up to date. -Andy > -Original Message- > From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 29, 2002 8:30 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] _SERVER variable insd prnt sttmnt > > > > > // print "" . > > This is the problem with not breaking out of a string to display > a variable. > Ideally, you would do it this way: > > print ""; > > But some people just have a problem with doing it that way, so you can use > braces. > > print ""; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] _SERVER variable insd prnt sttmnt
> > //print "" . This is the problem with not breaking out of a string to display a variable. Ideally, you would do it this way: print ""; But some people just have a problem with doing it that way, so you can use braces. print ""; If you don't use the braces, how is PHP supposed to know what you mean. Do you mean to print a variable called $_SERVER, followed by a literal ['PHP_SELF'], or do you mean an array? How is PHP supposed to decide for you? Like your second variable, $chars. Is that an array? Do you mean to print out the value of an $chars element, or do you mean to print out value of $char, followed by "[", value of $cnt, followed by "]" ?? Hope that helps. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] _SERVER variable insd prnt sttmnt
On Monday 29 April 2002 23:05, Kirk Babb wrote: > Hi All, > > Thanks alot for all your help with the _SERVER['PHP_SELF'] earlier, I have > another question related to that: > > What is the correct syntax for the above if I want to use it in a print > statement like so (I included the whole piece of code so you guys could at > least see what I'm trying to do): > > $string="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; > $chars = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY); > for ($cnt=0; $cnt < 26; $cnt++) { > //commented out the next line since I couldn't get it to work > //print "" . Normally you would use: $_SERVER['PHP_SELF'] But inside a double-quoted string like above you would use: $_SERVER[PHP_SELF] -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Work expands to fill the time available. -- Cyril Northcote Parkinson, "The Economist", 1955 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php