please help me with this example.. I want to call the function inside the class..
FUNCTION
class myTest(){
function Me(){
$x = 2;
}
}
is this the answer?
$myval = new myTest();
echo $myval;
thank you
please help me with this example.. I want to call the function inside the class..
FUNCTION
class myTest(){
function Me(){
$x = 2;
}
}
is this the answer?
$myval = new myTest();
echo $myval;
thank you
You need to first instantiate a new object of type 'myTest' like so:
$myObj = new myTest;
And then you can use the function like so:
$myObj->Me();
Note that at present, the function returns nothing so you'll get a 'blank screen'.
If you changed your function to read:
return "Hello";
Then you would get 'Hello' printed on screen by using the above.
I hope that helps?
$myval = new myTest();
here $myval
is object of the your Class .
You can call the inside function with just $myval->Me();