How do I find the name of a file using a class? For example: index.php
include 'class.php'
$class = new class();
How would you find the file (in this example index.php) inside of class.php?
How do I find the name of a file using a class? For example: index.php
include 'class.php'
$class = new class();
How would you find the file (in this example index.php) inside of class.php?
$class = new MyClass();
$class->file = __FILE__;
You could pass it to the constructor if you define your class accordingly
class MyClass {
public $file;
public function __construct($file){
$this->file = $file;
}
$class = new MyClass(__FILE__);