PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
How would this fail to open a subdirectory? PHP is telling me it's not looking up a directory and then in the templates directory but rather it's looking inside the same directory as the file this code is on?
JAB Creations wrote:How would this fail to open a subdirectory? PHP is telling me it's not looking up a directory and then in the templates directory but rather it's looking inside the same directory as the file this code is on?
The path is relative the script you're calling in your web browser, not the file that has the include() statment. If you want a path relative to the actual file you need to do this:
Actually this is an issue I'd like to bring up, perhaps I'm just not getting something or I've forgotten something I used to know but, how exactly does the PATH_SEPARATOR constant improve extensibility?
ole wrote:Actually this is an issue I'd like to bring up, perhaps I'm just not getting something or I've forgotten something I used to know but, how exactly does the PATH_SEPARATOR constant improve extensibility?
I've avoided bringing this up for fear of looking stoopid. But yes indeed, it seems like a pointless constant. PHP handles paths with "/" on *all* platforms. You should just stick with a slash for readability. Like ~ole says though, am I missing something?
What happens if future release change? The argument that '/' is treated the same on all platforms could be easily transposed onto the argument that $HTTP_SERVER_VARS will be a standard in the PHP core, or that short tags will always be available.
I know it seems like right now there is no need for it. But that is almost like saying three years ago that there really is no need to use <?php since PHP knows what to do with <?. Know what I mean?
I don't think you can reasonably protect yourself from unpublished changes to the language itself. I mean, when does it end? They could potentially decide to change anything.
If it was published that the path separator might change I would definitely be using it. I wouldn't mind so much but its such a long name as well.
ole wrote:Actually this is an issue I'd like to bring up, perhaps I'm just not getting something or I've forgotten something I used to know but, how exactly does the PATH_SEPARATOR constant improve extensibility?
I've avoided bringing this up for fear of looking stoopid. But yes indeed, it seems like a pointless constant. PHP handles paths with "/" on *all* platforms. You should just stick with a slash for readability. Like ~ole says though, am I missing something?
What about macs? DIRECTORY_SEPERATOR will contain whatever the the OS specific directory seperator is whether it is /, \, :, etc
Just like to clarify a bit of confusion: PATH_SEPARATOR has the value of ':' and is used for separating multiples paths like in the args to set_include_path(). So this is incorrect:
What about macs? DIRECTORY_SEPERATOR will contain whatever the the OS specific directory seperator is whether it is /, \, :, etc
For this reason DIRECTORY_SEPARATOR has its uses. But I'm trying to asertain whether PHP cares this. I have a hunch it's not bothered either way. The manual isn't particularly clear.
ole wrote:Just like to clarify a bit of confusion: PATH_SEPARATOR has the value of ':' and is used for separating multiples paths like in the args to set_include_path().
I was just about to point that out.
I'm not too sure on the reasons why to use PATH_SEPERATOR, but thats what I was taught to use. I always just assumed that for some reason there were some OS's that it was different on.
ole wrote:For this reason DIRECTORY_SEPARATOR has its uses. But I'm trying to asertain whether PHP cares this.
As far as im aware with this, PHP uses '/' on all platforms. I only use DIRECTORY_SEPARATOR when i have to pass a filepath off to some external program.