class Products {
protected $id;
public function setId($id)
{
return $this->id = $id;
}
public function getProduct()
{
$arr_list = [
[
'name'=>'Proton',
'year' => 1987
],
[
'name'=>'Produa',
'year' => 1990
],
];
return $arr_list;
}
public static function product_list()
{
//whatever data want to return
$arr_list = [
[
'name'=>'Proton',
'year' => 1987
],
[
'name'=>'Produa',
'year' => 1990
],
];
return $arr_list;
}
}
//static can call directly
$lists = Product::product_list();
//non static
$product = new Product();
$lists = $product->getProduct();
//when calling class must alert memory consume.