[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

realpath() returns empty string

Posted on 2012-09-17
10
Medium Priority
?
1,215 Views
Last Modified: 2012-11-07
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?
0
Comment
Question by:SheppardDigital
  • 6
  • 4
10 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 38406891
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.
0
 

Author Comment

by:SheppardDigital
ID: 38406978
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.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 38407095
... 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?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:SheppardDigital
ID: 38408305
Using var_dump() it just outputs bool(false)
0
 

Author Comment

by:SheppardDigital
ID: 38408366
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.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 38408938
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?
0
 

Author Comment

by:SheppardDigital
ID: 38408945
I believe it's supposed to convert it to...

"/home/webdev/public_html/appdev/application"
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 38409080
0
 

Accepted Solution

by:
SheppardDigital earned 0 total points
ID: 38559795
Hi Ray,

Sorry, we're running on a linux server so I'm afraid that wasn't applicable.

We moved the site to another server which resolved the problem.
0
 

Author Closing Comment

by:SheppardDigital
ID: 38575243
Problem was not really resolved, but we moved servers which fixed it.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month17 days, 20 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question