Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check for /lang/, which should be lang/
#2
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:
Code:
$a = explode('\\', $_SERVER['PHP_SELF']);
array_pop($a);
define('PATH', implode('/', $a));
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:
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__));
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.
Found my post helpful? Rate me Big Grin
Project: creating a compact and easy to setup DSLan (Linux) (Windoze is in development)


Messages In This Thread
RE: 1.4] Check for /lang/, which should be lang/ - by Lekensteyn - 22.08.2010, 21:01



Users browsing this thread: 1 Guest(s)