1.2.948. PHP7 Dirname¶
<?php
$path = '/a/b/c/d/e/f';
// PHP 7 syntax
$threeFoldersUp = dirname($path, 3);
// PHP 5 syntax
$threeFoldersUp = dirname(dirname(dirname($path)));
// long path, with backtracking
$path = __DIR__.'/../../../abc';
// short path, with direct access
$path = dirname(__DIR__, 3).'/abc';
?>
See also dirname.
1.2.948.1. Suggestions¶
Use dirname()’s second argument
1.2.948.2. Specs¶
Short name |
Structures/PHP7Dirname |
Rulesets |
All, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56, Suggestions, php-cs-fixable |
Exakat since |
0.8.4 |
PHP Version |
With PHP 7.0 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Examples |
|
Available in |