Forum Moderators: coopster

Message Too Old, No Replies

Differences when specifying paths in Linux/Windows

         

Tourex

10:48 am on Oct 26, 2005 (gmt 0)

10+ Year Member



I develop my scripts on a Windows platform but run the webs on a Linux server. I'm new to PHP and admit that I get in an awful mess when trying to specify paths in general scripts that might be called by pages in various folders.

I would like to use a configuration file in each script that will extract/set the root path for the site, depending upon whether it is on the Windows platform or on Linux. No problem! However, how do I call that config.php file from within the scripts without facing the same problem?

henry0

11:05 am on Oct 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Tourex
We had that topic yesterday


Look Here
[webmasterworld.com]

Consider only the thread first part.

Tourex

12:00 pm on Oct 26, 2005 (gmt 0)

10+ Year Member



Thanks Henry. I did see that but it seems to relate to adding something to php.ini and didn't make any sense to me anyway.

Perhaps I'm not explaining myself properly. Let me try again.

Say I've got a small search form that calls search.php from any page, anywhere in the site. The search script is located in the scripts folder off the root of the web. The trouble is, the root is different on my Windows machine than on the virtual server on the Linux host. So, for the active web I would normally call the script up via /scripts/script.php and know that it will work regardless of what folder/page calls it. But this path doesn't work on Windows.

I would therefore like to call $root_path/scripts/script.php where $root_path has been determined by an initialisation script.

henry0

1:38 pm on Oct 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



An option comes in mind
since you might have two dif versions of PHP
test bed and production server
you can check for phpversion()
then depending on the version serve one or the other path
echo phpversion() . "\n";