php.net |  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
Votes:3
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-04-17 19:50 UTC] fb at fbeyer dot com
Description:
------------
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

<?php
// 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

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

http://php.net/manual/en/language.constants.predefined.php

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