When you instantiate
$myNewClassObject
in the main file, you are doing it in the global scope. This means that the body of your
repeat
function doesn't have access to it. You can do either of the following:
1. Declare
$myNewClassObject
as global:
function repeat()
{
global $myNewClassObject;
$myNewClassObject->myFunction("source");
}
2. Make your entire
main
file into a class itself, with
$myNewClassObject
as a member variable which you can then access via
$this->myNewClassObject
. This avoids having globals which can get a little messy with large scripts.