Opened 10 years ago
Closed 10 years ago
#36963 closed enhancement (duplicate)
a little performance improvment: replace dirname(__FILE__) with __DIR__
| Reported by: | nigro.simone | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 4.5.2 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | performance |
Description
A little performance improvment is replace
dirname(__FILE__)
with
__DIR__
Their result is exactly the same ; so, no difference on that.
For example, the two following lines :
<?php var_dump(dirname(__FILE__)); var_dump(__DIR__);
Will both give the same output :
string '/htdocs/wordpress' (length=17)
But, there are at least two differences :
1) _DIR_ only exists with PHP >= 5.3
2) _DIR_ is evaluated at compile-time, while dirname(_FILE_) means a function-call and is evaluated at execution-time, so, _DIR_ is faster.
Change History (1)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Duplicate of #32274.