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 can I do a conditional include. I would like to include one file or another file. At first time I've simple made two includes and It was working on my windows machine but when I export my code to a unix machine I got a critical error where it fail to open the file.
Though i'm not sure why you are having problems in the first place, if you use relative paths then you should be able to include the same file across all OS's *shrug*
No, you dont understand what I mean, the file doesn't depends on the systems I have a file that is share between other file.
and I have in my code
include('./myconfig.php');
include('../myconfig.php');
because the file are situated in different directories. So I need something that include one of this two file. It doesn't depends on the systems. With windows I have no warning displayed but with unix I have warning. So I need to make it properly.
It's much easier to put included files inside the include_path. Then you can include 'myconfig.php' from anywhere and in any directory and it will always find it (so you don't need all that . ../.. type stuff).
You need to include ONE of the two files you mentioned - but under what condition? I.e. what causes one to be included but not the other one? Do you mean you want to check to see if the file exists and if it doesn't, you try and include the other one?
And now, everything is OK, This is good to know that.
admin is the name of a directory so basename will return '' because getcwd return the current path and basename the name of the file, as there is no file, it will return ''.
ppswing wrote:
admin is the name of a directory so basename will return '' because getcwd return the current path and basename the name of the file, as there is no file, it will return ''.
basename -- Returns filename component of path
So its weird that it returns your user directory
But if we consider that in Unix everything is a file, you're right.
perhaps my host is not using the same implementation of php
basename works on a string, it doesn't ever touch the filesystem. Thus there's no difference between filename and directory name as far as basename concerned.