22.08.2010, 21:01
Please don't hardcode \ as a directory separator, but use the PHP constant DIRECTORY_SEPARATOR.
It's strongly discougared to use $_SERVER['PHP_SELF'] for determining the path, unless you're REALLY sure about what you're doing.
The problem described is caused by assuming that the directory separator is always '\'.
This is not the case on Linux and Mac, it's '/'.
You're doing something like:
This is completely wrong, as PHP_SELF can contain pathinfo, and the directory separator does not have to be '\'.
So this happens on a Linux system:
A better approach would be:
Note: you can't use the magic constant __DIR__, that's available from PHP 5.3.0.
Source: http://nl.php.net/manual/en/language.con...efined.php
Now clean that messy code up.
It's strongly discougared to use $_SERVER['PHP_SELF'] for determining the path, unless you're REALLY sure about what you're doing.
The problem described is caused by assuming that the directory separator is always '\'.
This is not the case on Linux and Mac, it's '/'.
You're doing something like:
Code:
$a = explode('\\', $_SERVER['PHP_SELF']);
array_pop($a);
define('PATH', implode('/', $a));
So this happens on a Linux system:
Code:
$a = array('/opt/twlan/htdocs/include.inc.php');
array_pop($a);//returns '/opt/twlan/htdocs/include.inc.php'
// $a = array() (empty!)
define('PATH', explode('', array()));//yields ''
A better approach would be:
Code:
define('PATH', dirname(__FILE__));
Source: http://nl.php.net/manual/en/language.con...efined.php
Now clean that messy code up.
Found my post helpful? Rate me
Project: creating a compact and easy to setup DSLan (Linux) (Windoze is in development)