I have 3 files, 2 of the files instantiate my myclass
class. To determine which file they came from I want to pass a variable through to the class and then be able to output different content.
<?php
// File 1
$file1variable = '1';
$go = new myclass( $file1variable );
// File 2
$file2variable = '2';
$go = new myclass( $file2variable );
// File3
class myclass {
public function __construct() {
$this->display();
}
public function display() {
if( $file1variable ) {
echo 'file1';
} elseif( $file2variable ) {
echo 'file2';
}
}
}
?>
I have read up on reflection classes and this article PHP: How to instantiate a class with arguments from within another class but can't seem to get this to work for my scenario.
How can I achieve this?