PHP 8.5.0 Alpha 1 available for testing

Voting

: max(zero, seven)?
(Example: nine)

The Note You're Voting On

Anonymous
10 years ago
If you want the path to an file if you have i file structure like this

project -> system -> libs -> controller.php
project -> system -> modules -> foo -> foo.php

and foo() in foo.php extends controller() in controller.php like this

<?PHP
namespace system\modules\foo;

class
foo extends \system\libs\controller {
public function
__construct() {
parent::__construct();
}
}
?>

and you want to know the path to foo.php in controller() this may help you

<?PHP
namespace system\libs;

class
controller {
protected function
__construct() {
$this->getChildPath();
}
protected function
getChildPath() {
echo
dirname(get_class($this));
}
}
?>

<?PHP
$f
= new foo(); // system\modules\foo
?>

<< Back to user notes page

To Top