Page 1 of 1

meaning of this '->' symbol

Posted: Thu Mar 13, 2008 4:06 pm
by reddy1198
Hi

I am lerner of php Could you please explain me what is the meaning of following code....

Code: Select all

<?php
/* my Reporting System */
require_once("report.bbrain.php");
$sm = new smr;
$mymonth=4;
$myyear=2007;
 
    $sm->getMonthlyStats($mymonth, $myyear);
what it returns.....?

Thanks,
Srinivas

Re: meaning of this '->' symbol

Posted: Thu Mar 13, 2008 4:09 pm
by kryles
it is a function (or method) that is part of a class


className->method(variables)

what it returns (if anything) totally depends on the method itself.

Code: Select all

 
function Example()
{
return "abscgh";
}
 
this would return the string if called with smr->Example();

you'd want to store it is something.

Code: Select all

$stringvar = smr->Example();
sm is an instance of the class smr. which means it is a blank new copy.

so you'd do $stringvar = sm->Example();

and the include just makes the code in that file usable in the file you are working in

Re: meaning of this '->' symbol

Posted: Thu Mar 13, 2008 7:04 pm
by Christopher

Code: Select all

// this line create an object from a class named "smr"
$sm = new smr;
 
// this line call the "getMonthlyStats" function in the "smr" class
// the call use the $sm object's data
$sm->getMonthlyStats($mymonth, $myyear);