D
Returns the directory separator.
The purpose of this constant is to keep the file path pattern compatible on different operating systems. Mainly to distinguish between Linux and Windows operating systems. On Windows, the directory separator is '\'
, although Windows also accepts '/'
as its directory separator which then makes you think, perhaps, by converting all directory separators to '/'
is sufficient to make the file path pattern compatible on both operating systems.
require PATH . D . 'foo' . D . 'bar' . D . 'baz.php';
The main purpose of prioritizing the D
constant over a '/'
string literal when making a file path is to keep the process of manipulating a file path string consistent on all operating systems. We never know what type of directory separator will be passed from the __DIR__
constant so the below manipulation will most likely give different results on different operating systems.
// Assume that `__DIR__` is `'./srv/http/engine'` on Linux
// and `'C:\Users\Taufik\Server\http\engine'` on Windows
$file = __DIR__ . '/kernel/anemone.php';
// On Linux, this will return `'./srv/http/application/kernel/anemone.php'` as you would expect
// On Windows, this will return `'C:\Users\Taufik\Server\http\engine/kernel/anemone.php'`
echo strtr($file, ['/engine/' => '/application/']);
D
Returns the directory separator.
ENGINE
Returns the engine folder path.
LOT
Returns the lot folder path.
N
Returns the line ending character of current operating system.
PATH
Returns the application root path without the trailing directory separator.
P
Returns a placeholder character.
S
Returns an empty space character.
TEST
Disables or enables test mode.
VERSION
Returns the current application version.