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 #175283 is a reply to message #175278] Wed, 31 August 2011 12:59 Go to previous messageGo to previous message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma:
Senior Member
On 8/31/2011 7:22 AM, Jerry Stuckle wrote:
> 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.
>

If you, like most people, move a file it is not only that single file.
It is a whole directory tree. Using $_SERVER['DOCUMENT_ROOT'] would
then break the code whereas dirname(__FILE__) would not. I don't know
about you, but I don't just wake up one morning and say "gee, I think
I'll move that file". If I move anything, it is an entire directory
tree. If I have to move just a single file, I do a grep for that
filename and I also look inside that file for dependencies. How about you?

--
Shelly
[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 14:00:33 GMT 2024

Total time taken to generate the page: 0.03846 seconds