SheppardDigital
asked on
realpath() returns empty string
Hi,
I'm looking at a project for a client and I've noticed that realpath() is returning an empty string?
defined('APPLICATION_PATH' ) || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
Does anyone know why this might be? The site is hosted on a cloud hosting solution, could that have something to do with it as I read somewhere that realpath only works if you have certain permissions on folders?
I'm looking at a project for a client and I've noticed that realpath() is returning an empty string?
defined('APPLICATION_PATH'
Does anyone know why this might be? The site is hosted on a cloud hosting solution, could that have something to do with it as I read somewhere that realpath only works if you have certain permissions on folders?
ASKER
The issue definitely seems to be the realpath function. If I remove that and output the value of the APPLICATION_PATH, then there's something to output, but if I run the output through the realpath() function, it comes back empty.
... it comes back empty.Would that mean empty as in the PHP function call empty()? What is the output if you use var_dump() to print out the values of these variables and function calls?
ASKER
Using var_dump() it just outputs bool(false)
ASKER
I copied the site files to a server of my own this morning, and I'm still getting the same problem.
I don't understand why it's returning false.
My PHP version is 5.3.4
Just to confirm
------------------------
defined('APPLICATION_PATH' )
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
var_dump(APPLICATION_PATH) ;
------------------------
Outputs...
"Bool(false)"
If I remove the realpath() function from the line, I get this..
"/home/webdev/public_html/ appdev/sal onspy/../a pplication "
I could use a function to replace realpath, but this site uses the Zend framework and I've no idea how often the realpath() function is used within the site.
I don't understand why it's returning false.
My PHP version is 5.3.4
Just to confirm
------------------------
defined('APPLICATION_PATH'
|| define('APPLICATION_PATH',
var_dump(APPLICATION_PATH)
------------------------
Outputs...
"Bool(false)"
If I remove the realpath() function from the line, I get this..
"/home/webdev/public_html/
I could use a function to replace realpath, but this site uses the Zend framework and I've no idea how often the realpath() function is used within the site.
You might consider using a code scanner to look for other occurrences of realpath(). I have found that Textpad's "Find in Files" functionality is pretty good. Most editors have something like that.
Just curious... If you're getting this...
"/home/webdev/public_html/ appdev/sal onspy/../a pplication "
... what is realpath() supposed to do with that string?
Just curious... If you're getting this...
"/home/webdev/public_html/
... what is realpath() supposed to do with that string?
ASKER
I believe it's supposed to convert it to...
"/home/webdev/public_html/ appdev/app lication"
"/home/webdev/public_html/
Is this note applicable?
http://us2.php.net/manual/en/function.realpath.php#88964
http://us2.php.net/manual/en/function.realpath.php#88964
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Problem was not really resolved, but we moved servers which fixed it.
http://us.php.net/manual/en/function.realpath.php
As you can see, your OS and release levels matter. You might start by printing out the value of __FILE__, next printing the value of dirname(), etc. Drill down into the function calls to isolate and visualize the return values from these functions one layer at a time.