How can I call a class function in a global function with an object or included class file.
cls.php is the class file being used.
class tst
{
public function abc($i)
{
return $i * $i;
}
need to call the abc() method in xyzfunction in file two.php
include('cls.php');
$obj = new tst();
function xyz($j)
{
$result = $obj->abc($j);
return $result;
}
echo xyz(5);
Calling $obj->abc($j) is not working. How can I call function abc()?
$objvariable as a parameter to functionxyz(5,$obj) .. function($j,$obj){ }