Re: A Strange Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20 Jun 2013, at 18:39, Tedd Sperling <tedd@xxxxxxxxxxxx> wrote:

> Hi gang:
> 
> I have a very strange problem.
> 
> I can use this statement in one folder:
> 
> 	$fcontents = file('docs/admin-email.txt');
> 
> But in a different folder with an exact path having 'docs/admin-email.txt', I get:
> 
> Warning: file(/docs/admin-email.txt) [function.file]: failed to open stream: No such file or directory in <cut> on line 83
> 
> This has got me really puzzled.
> 
> I have confirmed these are the exact same folders and files, except only in two different places on the server. Both are one level down from root.
> 
> Any ideas as to what is going on?
> 
> Cheers,
> 
> tedd

Whatever the reason for this, I'd recommend you always specify a path relative to the current script.

In PHP 5.3+:

$fcontents = file(__DIR__.'/docs/admin-email.txt');

Prior to 5.3:

$fcontents = file(dirname(__FILE__).'/docs/admin-email.txt');

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux