After much searching, I can't seem to find any definitive way to
determine which path separator to use. Obviously, it's ":" on nix, and
";" on windows ... so what's the best way to determine what OS I'm
running on?
I've got a functional hack in place. But ... well, it's a hack.
Essentially, if my docroot begins with a "/" I just assume it's nix. So
far, it works. But I can't imagine I'm the first person to need this.
usenet searches haven't revealed much on the topic.
--cd 7 5636
Coder Droid wrote: After much searching, I can't seem to find any definitive way to determine which path separator to use. Obviously, it's ":" on nix, and ";" on windows ... so what's the best way to determine what OS I'm running on?
I've got a functional hack in place. But ... well, it's a hack. Essentially, if my docroot begins with a "/" I just assume it's nix. So far, it works. But I can't imagine I'm the first person to need this. usenet searches haven't revealed much on the topic.
There's the PHP_OS constant. It's been a while since I've done any PHP
programming on Windows so I'm not sure exactly what it'll be set to on
Windows, and a quick Google didn't quite clear that up either.
However, this should be fairly safe:
if(strpos(PHP_OS, "WIN") !== false) {
$separator = ';';
}
else{
$separator = ':';
}
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
> There's the PHP_OS constant.
Weird. In all my searching, never came across that. Of course, now that
I know it's there, I zoomed right into it in the documentation. So
obvious now...
Thanks so much for the tip.
--cd
Well, PHP_OS isn't quite as helpful as I thought. Like you, I can't seem
to find a definitive list of all possible OS's supported. So I'm left
with "does it contain 'win' anywhere in it?" and, if not, let's just
assume the path separator is :, which should work for everything else
(linux, aix, darwin, etc.) Except for probably OS/2, but I doubt I'm
going to have to worry about that that kind of portability for a while.
I guess what PHP really needs is a global PHP_PATH_SEPARATOR. :)
--cd
"Coder Droid" <co********@likethiswouldstopspam.hotmail.com> wrote in message news:<yZ*******************@fe1.texas.rr.com>... After much searching, I can't seem to find any definitive way to determine which path separator to use. Obviously, it's ":" on nix, and ";" on windows ... so what's the best way to determine what OS I'm running on?
Perhaps...
<?php
echo PATH_SEPARATOR;
print_r(get_defined_constants());
?>
--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Coder Droid wrote: Well, PHP_OS isn't quite as helpful as I thought. Like you, I can't seem to find a definitive list of all possible OS's supported. So I'm left with "does it contain 'win' anywhere in it?" and, if not, let's just assume the path separator is :, which should work for everything else (linux, aix, darwin, etc.) Except for probably OS/2, but I doubt I'm going to have to worry about that that kind of portability for a while.
I guess what PHP really needs is a global PHP_PATH_SEPARATOR. :)
You may want to peruse http://www.php.net/manual/en/reserve...s.standard.php
(Which includes the constant "PATH_SEPARATOR")
> You may want to peruse http://www.php.net/manual/en/reserve...s.standard.php
(Which includes the constant "PATH_SEPARATOR")
Well, slap my ass and call me sally. I don't know how many times I
searched for "path" "separator" and just couldn't come up with
*anything*. Seriously. I mean, I searched a lot, and I'm usually pretty
good at that. Quite flummoxed over this obvious miss!
[slinks away, but with thanks]
--cd
Coder Droid wrote: You may want to peruse
http://www.php.net/manual/en/reserve...s.standard.php
(Which includes the constant "PATH_SEPARATOR")
Well, slap my ass and call me sally. I don't know how many times I searched for "path" "separator" and just couldn't come up with *anything*. Seriously. I mean, I searched a lot, and I'm usually pretty good at that. Quite flummoxed over this obvious miss!
No matter how well you think you know a language there's always something
new you didn't know... wish I'd known about that constant a few years ago.
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hal Vaughan |
last post by:
I want to have a config file for my program, which means I need to know
where the config file is. If I type:
java myclass
and it runs myclass.class, is there any way to obtain the location of...
|
by: Stephen Ferg |
last post by:
I have a question that is not directly Python-related. But I thought
I'd ask the most erudite group that I know... :-)
When did Windows start accepting the forward slash as a path separator...
|
by: could ildg |
last post by:
I want to import c:\xxx\yyy\zzz.py into my programme,
What should I do?
Thank you~
|
by: Fred Nelson |
last post by:
I'm devloping a Web Application in VB.NET. In my web.config file I have
specified that untrapped errors are to be sent to the page "errorpage.aspx".
This is working fine - if an untrapped error...
|
by: André Nogueira |
last post by:
Hi there.
I know you can view a node's fullpath property, but is it posible to select
a node using its path?
Like, tell the treeview that the node that should be selected is the node
with the...
|
by: Phil Galey |
last post by:
In VB.NET, when you use shell or have a process object point to and run a
separate application that is installed on the machine, is there a way of
determining the path to the executable? I've been...
|
by: eliben |
last post by:
Hello,
os.path.split returns the head and tail of a path, but what if I want
to have all the components ? I could not find a portable way to do
this in the standard library, so I've concocted...
|
by: Aaron Gray |
last post by:
Has anyone got a code snippet to separate out the path components, ie drive,
path, filename, and extension ?
Many thanks in advance,
Aaron
|
by: mathieu |
last post by:
Hi there,
I do not understand what is going on with the following cmd line
(*). As specified I would like to compile the cs file:
C:/cygwin/home/mmalaterre/Projects/gdcm/trunk/Examples/Csharp/...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |