basename doesn't work on my local machine running windows but is fine ater uploaded to my hosting company machine. Are there certain functions of php engine that I have to turn on or off on my local machine?
Thanks.
basename doesn't work on my local machine running windows but is fine ater uploaded to my hosting company machine. Are there certain functions of php engine that I have to turn on or off on my local machine?
Thanks.
does not work means php doesn't know the function?
if php knows [man]basename()[/man] (what it should since basename exists since php 3) what does it output and what should it output?
basename IS a php function. It produces a file name without directory prefix. It works on some machines but not the one I am using with phpdeve bundle (apache, php, mysql) installed.
Originally posted by mrhappiness
does not work means php doesn't know the function?
if php knows [man]basename()[/man] (what it should since basename exists since php 3) what does it output and what should it output?
Could you provide an example where it does not work?
There doesnt seem to be any option to turn off basename() at PHP's compile-time, and at runtime there isnt any reason why basename() should not work, unless you are not using it correctly.
Thanks for looking into this, laserlight. The code looks like this. I put it at the beginning of a file, and use the $filename in a condition.
<?
$filename = basename($PHP_SELF);
echo $filename;
?>
It displays nothing. As I said, it works on some computers but not this particular one.
Appreciate your help.
try this
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo $filename_1 = basename($PHP_SELF);
echo '<br />';
echo $filename_2 = basename($_SERVER['PHP_SELF']);
i think you maybe have register_globals switched off
mrhappiness,
It works! here is what I got when I tried yours:
Notice: Undefined variable: PHP_SELF in c:\phpdev\www\welgen\basename.php on line 4
basename.php
I will turn the register_global on. Thank you so much.
i would rather advice using $_SERVER and all the other superglobal arrays
Agreed: register_globals was turned off for a reason.