This is a very basic php question : suppose I have 3 files, file1, file2, file3.
In file1 I declare a class called Object. In file2, I have a method that instantiate Object, call it $object, and call this method Method
In file2, this method looks like
public function Method(){
$object = new Object;
...
require_once(file3);
$anotherobject = new AnotherObject;
$anotherobject->method();
}
Finally, in file 3 I declare another AnotherObject. So, if I have a method ‘method’ in file3, can I refer to $object’s properties directly, or could I access ony the static method of Object ?
This is not how decent OOp should be programmed. Give each class its own file. As I understand it you have 3 files with classes in them and want to use a the instantiated objects. Use Dependency Injection to construct classes that depend on each other.
Example:
file1.php:
file2.php, uses instantiated object:
file3.php, uses multiple instantiated objects:
Tie all this together in a bootstrap file or some kind of program file:
program.php: