FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » fopen Problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: fopen Problem [message #175278 is a reply to message #175277] Wed, 31 August 2011 11:22 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 8/31/2011 6:49 AM, A wrote:
>> $_SERVER['DOCUMENT_ROOT'] . '/logbooks/CAA001/blahblah.txt'.
>>
>> dirname(__FILE__) is a very bad way to to it - it is dependent on the
>> location of the script opening the file and will break if you move the
>> script to a different directory.
>
> if I understood the question correctly the file is *NOT* on his own server
> because he allow_url_fopen configuration setting.
> dirname(__FILE__) is very useful. I tend to keep all my scripts in a
> relative file/folder structure so I WANT to move them and keep the paths
> properly in place.
>
>

Whether it is his own server or not is immaterial as it has no effect on
my statement.

And obviously you have not tried $_SERVER['DOCUMENT_ROOT'] = which also
allows you to keep your scripts in a file/folder structure. The
difference being dirname(__FILE__) changes depending on the calling
script's location = move the calling script and your code breaks.

For this reason it's a bad idea to use it to access other files unless
that file is *totally dependent* on the calling script and will *always*
be in the same relative location to the calling script. But such
assumptions also make the files more tightly coupled, creating
unnecessary dependencies.

$_SERVER['DOCUMENT_ROOT'] always points at the root directory of the
website and is independent of the calling script's location.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Strategic Marketing Summit 2011 (September 24th,Chennai)
Next Topic: does paypal standard method supports for recurring payment.
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 07:04:28 GMT 2024

Total time taken to generate the page: 0.03656 seconds