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 #175288 is a reply to message #175283] Wed, 31 August 2011 17:39 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 8:59 AM, sheldonlg wrote:
> 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?
>

I, like most GOOD programmers, keep included files in their own
directories, based on the file type. For instance, common PHP include
files are kept in one directory; class files in another, and protected
documents in a third (all outside the document root). That way there is
a common access to ALL files from anywhere in the site.

Only the actual web pages themselves are in the document root and its
subdirectories. And changing those changes the URL accessing the files.

No, I seldom move ANY files. Rather, I create a plan BEFORE I start
writing any code - it's all part of the design.

--
==================
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 21:57:48 GMT 2024

Total time taken to generate the page: 0.04601 seconds