Reputation:
index.php
include('./class1.php');
include('./class2.php');
$Func = new function();
$Func->testfuncton1();
class1.php
class controller{
public function test(){
echo 'this is test';
}
}
class2.php
class function{
public function testfuncton1(){
controller::test();
}
}
But we not get content from function test()
.
Tell me please where error ?
Upvotes: 1
Views: 10155
Reputation: 12834
Your issues:
class
named function
. function
is a keyword
.$Func
, but make call using $Function
If you remove these two issues, your code will work correctly:
class ClassController{
public function test(){
echo 'this is test';
}
}
class ClassFunction{
public function testfuncton1(){
ClassController::test();
}
}
$Func = new ClassFunction();
$Func->testfuncton1();
This should print this is a test
Upvotes: 8