Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to undersnatd OO php code

Status
Not open for further replies.

wolf73

Programmer
Feb 12, 2006
93
CA
I am trying to understand the following code. In the function below. Buyer is a class and , and it has a method find_all that we are calling right?
and then $this->sites is a variable, correct, to which we are assingning the value returned by method find_all, correct? But if I print
$this->sites, it prints an array? something like this

"Array ( [0] => Buyer Object ( [table_name] => buyers [database_connection_name] => [all_fields] => Array ( ) [integrity_errors] => "





*@var array
*/
protected $sites;
protected $site;



public $buyer_carrier_weight = Array();



public function mobilebuyers()
{
$this->sites = Buyer::find_all("Buyer");
// $this->render("list_buyers");

}
 
Since variables in PHP don't have explcit types the act of assiging a value to a variable, turns the variable into the type the value had.

Example:

$myvariable=1;
$othervariable="Soime string";
$myvariable=$othervariable;

?%myvariable started out being an integer, but when I assigned the value of $othervariable to it, it becomes a string.

So if find_all returns an array. assigning that to the variable turns the variable $sites into an array.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top