Link to home
Start Free TrialLog in
Avatar of SheppardDigital
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?
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Better than to read "somewhere" -- you can read on the official online documentation!
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.
Avatar of SheppardDigital
SheppardDigital

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?
Using var_dump() it just outputs bool(false)
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/salonspy/../application"

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/salonspy/../application"

... what is realpath() supposed to do with that string?
I believe it's supposed to convert it to...

"/home/webdev/public_html/appdev/application"
ASKER CERTIFIED SOLUTION
Avatar of SheppardDigital
SheppardDigital

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Problem was not really resolved, but we moved servers which fixed it.