I try to include a file and want to use a function from a other included file but i become this error
Call to a member function test() on null
this code works fine: index.php
<?php
include("Framework/ini.php");
$test = new testclass;
$test->x = 1;
$test->test();
?>
ini.php
<?php
class testclass {
public $x = 0;
function test(){
return $this->x;
}
}
?>
index2.php
<?php
echo $test->test();
?>
but if i include the file over the class i become the error index.php
<?php
include("Framework/ini.php");
$test = new testclass;
$test->x = 1;
$test->test();
?>
ini.php
<?php
class testclass {
public $x = 0;
function test(){
require_once("folder/index2.php");
}
}
?>
i want to include the file over the class. how i can solve this problem ?