statyczny php
<?php
//Explanation and features
//1- we can call the static methode and property without creating instance
//from the class => syntax to call is : classname::methodename(),ore propName.
// static property save the new value in the function .
class carA {
static private $color="red";
public static function size (){return "big"};
}
class carB { $color private $color =" black" ;
public function size (){return "small"};
//to access a static property to a public function in the same class =>
static private $price= 3000;
public function price(){
return self::$price;
}
}
$carOb = new carB();
echo $carOb->color;//output=>black;
echo $carOb->size();//output=>small;
echo $carOb->price();//output=>3000;
//to access to the static( property and methodes) className::propName/methodeName
echo carA::$color; //output is : red;
echo carA::size(); //output is : big;
AHMAD ALHAMADA