PHP construct: instantiating classes

The idea of object-oriented programming is much wider than the possibilities of PHP due to its specifics, but even in the existing implementation, it gives the programmer unlimited possibilities. The construct PHP construct is a special method of a class (object) that is called every time an instance of the class is created.

Php construct




The limitation is that PHP is working at the time of page formation. At the moment when the page is updated or another page of the same site is loading, the desired system of objects is formed again from scratch.

Creating an instance of a class

. , (), , PHP class construct .

- , ( ) . , .

, , (), function construct PHP .





php class construct




(PHP construct) (). __construct , .

PHP class construct




$iUniqueNo, . PHP .

, , , , . , .





public function construct php




parent:: . . , . , - .

, . .

function construct PHP




" " - , , , , .

, , - - . , PHP parent construct - .

. public function construct, PHP , .

public function construct PHP




private - , ?

- , , , .

- PHP construct class , , .

PHP parent construct




AJAX JavaScript , .

PHP , "", "" , , , - ++.

, "", . , ++, #, Pascal&Delphi. - , .

"" " ". . , ++ #, :

  • ;
  • .

- , , . , , .

, . , . - .

, - .

PHP construct , :

  • - ;
  • - .

PHP , , .

php construct




, . , ( , ), , , .

, . .

A self-preserving system of objects "remembers" the actions of the visitor and the state of the pages, and every time PHP starts, it is not created from scratch, but is restored to its previous state.




All Articles