Reply to Re: realpath(dirname(__FILE__)) returning empty string

Your name:

Reply:


Posted by Brendan Gillatt on 07/01/07 18:16

On Sat, 30 Jun 2007 14:18:37 -0700, "laredotornado@zipmail.com"
<laredotornado@zipmail.com> wrote:

>Hi,
>
>I'm using PHP 4.4.7. When I define a constant as
>
>define("SITE_ROOT_DIR", dirname(__FILE__));
>
>the result is the value ".". The real directory path should be "/home/
>myaccount/web". So I tried
>
>define("SITE_ROOT_DIR", realpath(dirname(__FILE__)));
>
>on the advice of another, but now I'm getting an empty string. Any
>ideas how to overcome this? I'd prefer not to hard code paths because
>my development server path is different.
>
>Thanks, - Dave

Which version of PHP are you using because, acording to the PHP
manual,

__FILE__

"The full path and filename of the file. If used inside an include,
the name of the included file is returned. Since PHP 4.0.2, __FILE__
always contains an absolute path whereas in older versions it
contained relative path under some circumstances."

__FILE__ could be returning something like ./somescript.php instead of
an absolute directory and therefore dirname() would only return ".".

If this is the case, try $_SERVER['SCRIPT_FILENAME']
--
Brendan Gillatt
www.brendangillatt.co.uk
GPG: 0x6E265E61

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация