|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #28040 __DIR__ - Another 'magic constant'
Submitted: 2004-04-17 19:50 UTC Modified: 2004-04-18 01:01 UTC
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: fb at fbeyer dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: fb at fbeyer dot com
New email:
PHP Version: OS:


 [2004-04-17 19:50 UTC] fb at fbeyer dot com
It would be extremely handy to extend the 'magic constant' family by __DIR__ - a constant poining to the directory where the current file is located, ending with a directory separator slash.

__DIR__ could be defined in user-land by

// Defined as constant - so it won't be usable for
// other files...
define('__DIR__', dirname(__FILE__) . DIRECTORY_SEPARATOR);

// Use __DIR__
require __DIR__ . 'another-file-for-this-library.php';

Many scripts (e.g. SMARTY_DIR) already define variables/constants for this purpose. __DIR__ would be a nice feature to write include_path independent scripts.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-17 20:23 UTC]
This would also ease writing test scripts.
 [2004-04-18 01:01 UTC]
Just use dirname(__FILE__) if you need this information, we will not add this.

 [2010-03-04 18:04 UTC] hellbringer at gmail dot com
"we will not add this"

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Dec 05 06:01:23 2020 UTC