RE: [PHP] How do I display the script file name?
How can I display the script file name? Presumably something like-: ?php echo $ScriptFileName; ? While I'm learning php and developing various Web page versions, I want to be sure the that the display is from the appropriate script. Regards Stephen Ford, Surrey, UK Try any of these to see if it is what you want - some are absolute some are relative ... ? echo $_SERVER['SCRIPT_NAME'].' '. $_SERVER['SCRIPT_FILENAME'].' '. $_SERVER['PHP_SELF']; ? Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I display the script file name?
emailed posted Thanks I'll post back with results. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I display the script file name?
The 'magic constant' __FILE__ is one way. ?PHP echo __FILE__; ? or even better: ?=__FILE__;? HTH, Jason k Larson Stephen Ford wrote: How can I display the script file name? Presumably something like-: ?php echo $ScriptFileName; ? While I'm learning php and developing various Web page versions, I want to be sure the that the display is from the appropriate script. Regards Stephen Ford, Surrey, UK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I display the script file name?
Partial success. The code and output are shown below. There are no errors. What does the .' '. do pls. Have tried a variety of combinations to see the effect. Nothing to see... :-( ===PHP== ?php echo PLine #1 .' '.$_SERVER['PHP_SELF'], /P; echo PLine #2/P; echo PLine #3/P; echo PLine #4 .' '.$_SERVER['SCRIPT_NAME'].' '. $_SERVER['SCRIPT_FILENAME'].' '. $_SERVER['PHP_SELF']./P; echo PLine #5/P; echo PLine #6 , __FILE__,/P; ? ===IE6 display=== Line #1 Line #2 Line #3 Line #4 Line #5 Line #6 Pathname removed for security == Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I display the script file name?
. is a string concatenation operator. ' or are strings. Read http://www.php.net/manual/en/language.operators.string.php By the way, __LINE__ is available in addition to __FILE__. Hope that helps, Jason k Larson Stephen Ford wrote: Partial success. The code and output are shown below. There are no errors. What does the .' '. do pls. Have tried a variety of combinations to see the effect. Nothing to see... :-( ===PHP== ?php echo PLine #1 .' '.$_SERVER['PHP_SELF'], /P; echo PLine #2/P; echo PLine #3/P; echo PLine #4 .' '.$_SERVER['SCRIPT_NAME'].' '. $_SERVER['SCRIPT_FILENAME'].' '. $_SERVER['PHP_SELF']./P; echo PLine #5/P; echo PLine #6 , __FILE__,/P; ? ===IE6 display=== Line #1 Line #2 Line #3 Line #4 Line #5 Line #6 Pathname removed for security == Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I display the script file name?
With the output you are getting you will not see the output from the .' '. As it inserts a space into the ouputted text. There is an error after the $_SERVER['PHP_SELF'] the , should be a . (is this just a typo in the e-mail?) Thanks Mark -Original Message- From: Stephen Ford [mailto:[EMAIL PROTECTED] Sent: 27 February 2003 16:47 To: [EMAIL PROTECTED] Subject: Re: [PHP] How do I display the script file name? Partial success. The code and output are shown below. There are no errors. What does the .' '. do pls. Have tried a variety of combinations to see the effect. Nothing to see... :-( ===PHP== ?php echo PLine #1 .' '.$_SERVER['PHP_SELF'], /P; echo PLine #2/P; echo PLine #3/P; echo PLine #4 .' '.$_SERVER['SCRIPT_NAME'].' '. $_SERVER['SCRIPT_FILENAME'].' '. $_SERVER['PHP_SELF']./P; echo PLine #5/P; echo PLine #6 , __FILE__,/P; ? ===IE6 display=== Line #1 Line #2 Line #3 Line #4 Line #5 Line #6 Pathname removed for security == Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I display the script file name?
Actually, echo can handle multiple arguments, which it thinks those are. echo 'foo', bar, $foobar; //one example //echo x3 echo 'foo'; echo bar; echo $foobar; echo 'foo'.bar.$foobar; //yet another echo example There are even more complex ways too and, of course, the use of ()s ... but I think I've made my point. HTH, Jason k Larson M.A.Bond wrote: With the output you are getting you will not see the output from the .' '. As it inserts a space into the ouputted text. There is an error after the $_SERVER['PHP_SELF'] the , should be a . (is this just a typo in the e-mail?) Thanks Mark -Original Message- From: Stephen Ford [mailto:[EMAIL PROTECTED] Sent: 27 February 2003 16:47 To: [EMAIL PROTECTED] Subject: Re: [PHP] How do I display the script file name? Partial success. The code and output are shown below. There are no errors. What does the .' '. do pls. Have tried a variety of combinations to see the effect. Nothing to see... :-( ===PHP== ?php echo PLine #1 .' '.$_SERVER['PHP_SELF'], /P; echo PLine #2/P; echo PLine #3/P; echo PLine #4 .' '.$_SERVER['SCRIPT_NAME'].' '. $_SERVER['SCRIPT_FILENAME'].' '. $_SERVER['PHP_SELF']./P; echo PLine #5/P; echo PLine #6 , __FILE__,/P; ? ===IE6 display=== Line #1 Line #2 Line #3 Line #4 Line #5 Line #6 Pathname removed for security == Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I display the script file name?
I've checked up on strings, and it seems like the quoting is like the Korn shell. You can see below that I found basename() which works fine with __FILE__, but $_SERVER['PHP_SELF'] etc print nothing. Any ideas? Stephen =PHP== ?php echo 'P$_SERVER[\'PHP_SELF\']= '.$_SERVER['PHP_SELF']./P; echo 'P$_SERVER[\'SCRIPT_NAME\'] (etc)='.$_SERVER['SCRIPT_NAME'].' '. $_SERVER['SCRIPT_FILENAME'].' '. $_SERVER['PHP_SELF']./P; echo 'P__FILE__='.__FILE__./P; echo 'P$SCRIPT_FILENAME='.$SCRIPT_FILENAME./P; echo PBasename=.basename(__FILE__)./P; ? ==IE6 Display= $_SERVER['PHP_SELF']= $_SERVER['SCRIPT_NAME'] (etc)= __FILE__=/path/sfindex03.php $SCRIPT_FILENAME=/path/sfindex03.php Basename=sfindex03.php === -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I display the script file name?
I disagree. While I tend to stay away from short tags in general, the use of the short echo tag has yet to cause any trouble for me. And it makes code exceptionally easier to read, which proves to be a valueable asset. Maybe you could provide and example where a short tag is causing some trouble. I'd like to see that. That is, unless it's not a PHP behavior problem, but a scripting or logic issue due to poor development. -- Jason k Larson Leif K-Brooks wrote: I think you mean worse. Short tags cause nothing but trouble. Jason k Larson wrote: or even better: ?=__FILE__;? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I display the script file name?
The ?xml tag not being allowed outside of PHP tags in one example. Code that relies on short tags also causes problems with portability, since it can't be moved to a server with short tags turned off. Jason k Larson wrote: I disagree. While I tend to stay away from short tags in general, the use of the short echo tag has yet to cause any trouble for me. And it makes code exceptionally easier to read, which proves to be a valueable asset. Maybe you could provide and example where a short tag is causing some trouble. I'd like to see that. That is, unless it's not a PHP behavior problem, but a scripting or logic issue due to poor development. -- Jason k Larson Leif K-Brooks wrote: I think you mean worse. Short tags cause nothing but trouble. Jason k Larson wrote: or even better: ?=__FILE__;? -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I display the script file name?
By including \n the html source looks like this, which is fine. I'll RTFM about $_SERVER and post back if in trouble. Thanks for help. Stephen P$_SERVER['PHP_SELF']= /P P$_SERVER['SCRIPT_NAME'] (etc)= /P P__FILE__=/path/sfindex03.php/P P$SCRIPT_FILENAME=/path/sfindex03.php/P PBasename=sfindex03.php/P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php