User Tools

Site Tools


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 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. ”



PSR-0 Autoloading Standard (PHP Standards Working Group)

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


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. ”


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

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


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