Re: Spaces in filenames [message #173704 is a reply to message #173703] |
Sat, 30 April 2011 11:33 |
Tim Streater
Messages: 328 Registered: September 2010
Karma:
|
Senior Member |
|
|
In article <eli$1104300232(at)qz(dot)little-neck(dot)ny(dot)us>,
Eli the Bearded <*@eli.users.panix.com> wrote:
> In comp.lang.php, Tim Streater <timstreater(at)waitrose(dot)com> wrote:
>> When my app starts up, it discovers where it has been installed using:
>>
>> $instdir = dirname (__FILE__);
>>
>> Now, I have no control over where this might be in the file system, and
>> the user may well put it somewhere such that the path contains spaces.
>> I'm passing this round the app, and in the fullness of time may be doing
>> things like:
>>
>> $fp = fopen ($instdir . "/wiggy", "r");
>
> Why? Just chdir() and use relative filenames. You'll save yourself
> a boatload of headache.
>
> $instdir = dirname (__FILE__);
> chdir($instdir);
> $fp = fopen ("./wiggy", "r");
:-)
I didn't bother to explain how my app is structured but I see I need to.
There are in fact 47 separate PHP scripts which are run by apache for
the user. Indeed, they run on the user's machine, not on a remote host,
along with an instance of apache also run under the user's id, and some
23 html pages which request the running of the PHP scripts. Note that
I'm not using port 80 for this and the apache instance only accepts
requests from localhost.
So I could chdir, but why bother. It would just be an extra, avoidable,
bunch of PHP statements.
--
Tim
"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
|
|
|