I am writing code that will operate both on the Mac and on Windows boxes. As anyone knows who has worked on both platforms, Mac and Windows paths are different. If I can tell which box the client is, I can construct the path according to that box's style. How can I tell what the client is.
1.) Specifically, I am downloading using FTP in PHP. How can I tell what the platform is?
2.) When the time comes to upload, from the client, do I need any special syntax in the path to let the script know that I am downloading from the client, or will FTP figure that one out?
I have looked at the PHP site and at the PHP references I have, but none of them cover it, that I can find out. I also looked at the $_SERVER array and found nothing helpful there without a lot of parsing
Understanding how to construct paths
Moderator: General Moderators
Re: Understanding how to construct paths
Code: Select all
if (stristr(PHP_OS, 'WIN')) {
// Windows
} else {
// Other
}I work on Win and publish to *nix and /var/www/htdocs is the same on both - they go to the root of the drive in win.
Re: Understanding how to construct paths
Yossarian:Yossarian wrote:
Thats how you can detect it, but why do you need to rewrite paths?
I work on Win and publish to *nix and /var/www/htdocs is the same on both - they go to the root of the drive in win.
I have years and years of experience in C++ and other languages (such as XBase), but hardly any in PHP. My newbie status on this board also reflects my status in writing PHP code.
In C++, one must take care to use the pathing style appropriate to the system. I admit that on Windows there are some concessions to Unix in that one can use either the "\" or the "/" to indicate directory level separation, but unless using the UNC, drive and path must be appropriately specified.
Thank you for the information. I will try both suggestions.
R,
Pedantic