1<?php
2class Car
3{
4 public function test($var = 'Hello kinjal')
5 {
6 $this->var = $var;
7 return $this->var;
8 }
9}
10class Bike
11{
12 public static function test($var)
13 {
14 $var = '<br>this is static function';
15 return $var;
16 }
17}
18$obj = new Car();
19echo $obj->test();
20echo Bike::test('this is non static'); //static function called using :: double colon
21
22?>
1
2<?php
3function foo(){
4 static $int = 0; // correct
5 static $int = 1+2; // correct
6 static $int = sqrt(121); // wrong (as it is a function)
7
8 $int++;
9 echo $int;
10}
11?>
12
13