User Tools

Site Tools


php:tips

PHP Tips

DIRECTORY_SEPARATOR is not necessary

“ In attempting to write cross-platform, portable PHP code, I used PHP’s DIRECTORY_SEPARATOR constant to write path strings, e.g. "..".DIRECTORY_SEPARATOR."foo", because the “proper” way to do it on Windows would be "..\foo" while on everything else (Linux, UNIX, Mac OS X) it would be "../foo". ”
“ Well, as Christian on php.net pointed out and the guys at Web Design Forums confirmed, that’s completely unnecessary. As long as you use the forward slash, "/", you’ll be OK. Windows doesn’t mind it, and it’s best for *nix operating systems. ”

Source: http://alanhogan.com/tips/php/directory-separator-not-necessary

Source: http://us2.php.net/manual/en/ref.filesystem.php#73954

PSR-0 Autoloading Standard (PHP Standards Working Group)

“ The following describes the mandatory requirements that must be adhered to for autoloader interoperability. ”

Source: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md

PSR-1 Basic Coding Standard (PHP Standards Working Group)

“ This section of the standard comprises what should be considered the standard coding elements that are required to ensure a high level of technical interoperability between shared PHP code. ”

Source: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md

PSR-2 Coding Style Guide (PHP Standards Working Group)

“ This guide extends and expands on PSR-1, the basic coding standard. ”

Source: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md

php/tips.txt · Last modified: 2013/11/26 14:38 (external edit)