meaning of this '->' symbol

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
reddy1198
Forum Newbie
Posts: 1
Joined: Thu Mar 13, 2008 3:59 pm

meaning of this '->' symbol

Post 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
kryles
Forum Contributor
Posts: 114
Joined: Fri Feb 01, 2008 7:52 am

Re: meaning of this '->' symbol

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: meaning of this '->' symbol

Post 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);
(#10850)
Post Reply