Hello;
 
I'm using PHP 4.2.3 on a Solaris 2.8 (Sparc) system.
 
I've been having some difficulties getting PHP-Nuke 6.0 to work for me.
I eventually narrowed the problem down to incorrect results from calls
to file_exists().  It seems that file_exists() is having trouble finding
an existing file within a subdirectory of the current directory -- IF I
use relative pathnames.  If I use absolute pathnames (specifically by
prepending the results of getpwd() as stored in a variable), then things
work fine - but clearly this shouldn't be necessary.
 
I've written a sample PHP script to illustrate the problem I'm having.
Below it can be found the output of having executed this script.  (You
can see it for yourself @ http://wireless.pleiades.com/jim.php).  As you
can see, only the third test works - and that's the one with $CurrentDir
prepended to the $targetfile...
 
This is probably a "doh!" kind of problem, but it's got me stumped.  Any
help would be appreciated.
 
Thanks,
 
Jim
 
 
 
================================================
<?php
$CurrentDir = getcwd();
 
echo "Current directory (saved as \$CurrentDir)
is:<br>[$CurrentDir]</br>";
 
$targetfile = "modules/News/index.php";
 
echo "<br>Test 1 - Relative Pathname.<br>Looking for [$targetfile]<br>";
if ( file_exists( "$targetfile" ) ) {              
    echo "- Found it.<br>";
} else {    
    echo "- Not found.<br>";
}
 
echo "<br>Test 2 - Relative Pathname with preceding './'<br>looking for
[./$targetfile]<br>";
if ( file_exists( "./$targetfile" ) ) {
    echo "- Found it.<br>";
} else {    
    echo "- Not found.<br>";
}
 
echo "<br>Test 3 - Absolute Pathname (By prepending
\$CurrentDir)<br>looking for [$CurrentD
ir/$targetfile]<br>";
if ( file_exists( "$CurrentDir/$targetfile" ) )
{
    echo "- Found it.<br>";
} else {  
    echo "- Not found.<br>";
}
?>
===================================================
 
 
 
OUTPUT:
--------------
 
Current directory (saved as $CurrentDir) is:
[/usr/local/websites/wireless.pleiades.com/html]

Test 1 - Relative Pathname.
Looking for [modules/News/index.php]
- Not found.

Test 2 - Relative Pathname with preceding './'
looking for [./modules/News/index.php]
- Not found.

Test 3 - Absolute Pathname (By prepending $CurrentDir)
looking for
[/usr/local/websites/wireless.pleiades.com/html/modules/News/index.php]
- Found it.

Reply via email to