Hi, I'm either coding this wrong or having a bad day. I need someone to varify this... Goal, to detect if a given path is not absolute. Now I've done this with a regular expression: "/([a-z]:\/|\/)/i" Basicly it detects if it starts with a drive letter (Windows) or '/' (Unix). I'm trying to get rid of the regex to speed up the script. So, I first test for a '/' then ':'. Now it has to be one or the other (Unix or Windows) so I use xor in my if statement. That doesn't work.! Either I have the logic wong or there is a bug or something. Try this out:
<?php
$dir = './test/dir';
if (!preg_match("/^([a-z]:\/|\/)/i", $dir))
print('not absolute1');
if ($dir{0} != '/' xor $dir{1} !=':')
print('not absolute2');
?>
What I get is the first if comes out not absolute but the second one does. Does anyone see what I'm doing wrong for the second if statement? Thanks
System: Apache 1.3.29 / PHP 4.3.4 / Windows 2k