php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #61298 Add an short alias DS for DIRECTORY_SEPARATOR
Submitted: 2012-03-06 06:39 UTC Modified: 2012-03-06 10:36 UTC
From: cornelius dot howl at gmail dot com Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 5.4.0 OS:
Private report: No CVE-ID: None
 [2012-03-06 06:39 UTC] cornelius dot howl at gmail dot com
Description:
------------
Really hope there is a DS alias for DIRECTORY_SEPARATOR, and PATH_SEPARATOR.

because it's too easy to make a typo, these keywords are hard to type.

$path = 'root' . DS . 'to' . 'path' . DS . 'subpath' . DS . 'subpath' . DS . 
'file.txt';

rather than:

$path = 'root' . DIRECTORY_SEPARATOR . 'to' . 'path' . DIRECTORY_SEPARATOR . 
'subpath' . DIRECTORY_SEPARATOR . 'subpath' . DIRECTORY_SEPARATOR . 'file.txt';

the later is uglier. 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-06 10:36 UTC] johannes@php.net
-Status: Open +Status: Not a bug
 [2012-03-06 10:36 UTC] johannes@php.net
Constants should have clear names to help readability. If you want something shorter you can easily do
    const DS = DIRECTORY_SEPARATOR;
or using define(). If you have issue typing names correctly you can also get an IDE.
 [2014-06-09 14:22 UTC] hanskrentel at yahoo dot de
Also nobody needs this constant. You can just use '/' (slash), it works.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 13:01:27 2024 UTC