PHP

PHP jest obiektowym, skryptowym jezykiem programowania zaprojektowanym do tworzenia dynamicznych stron www.


Funkcje PHP

Oficjalna strona PHP

Dodatkowe aplikacje PHP

Dodatkowe modu³y PHP

Wortal PHP
programy graficzne - systemy lotto - tarot darmowy - aparaty cyfrowe nikon - Żyrandole kryształowe - Mieszkania Poznań


Constructors and Destructors

Constructors and Destructors

Constructor

void __construct ( [mixed args [, ...]] )

PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.

Notatka: Parent constructors are not called implicitly if the child class defines a constructor. In order to run a parent constructor, a call to parent::__construct() within the child constructor is required.

Przykład 19-8. using new unified constructors

<?php
class BaseClass {
   function
__construct() {
       print
"In BaseClass constructor\n";
   }
}

class
SubClass extends BaseClass {
   function
__construct() {
       
parent::__construct();
       print
"In SubClass constructor\n";
   }
}

$obj = new BaseClass();
$obj = new SubClass();
?>

For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class. Effectively, it means that the only case that would have compatibility issues is if the class had a method named __construct() which was used for different semantics.

Destructor

void __destruct ( void )

PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed.

Przykład 19-9. Destructor Example

<?php
class MyDestructableClass {
   function
__construct() {
       print
"In constructor\n";
       
$this->name = "MyDestructableClass";
   }

   function
__destruct() {
       print
"Destroying " . $this->name . "\n";
   }
}

$obj = new MyDestructableClass();
?>

Like constructors, parent destructors will not be called implicitly by the engine. In order to run a parent destructor, one would have to explicitly call parent::__destruct() in the destructor body.

Notatka: Destructor is called during the script shutdown so headers are always already sent.

Notatka: Attempting to throw an exception from a destructor causes a fatal error.

Limo and Car services Airport chicago limo service 773-649-9630 - Limo and Car services limo service Airport chicago 773-649-9630 - Faktorowanie Faktury Program - załóż własne radio internetowe zupełnie za darmo - automatyczna aktywacja - galerie - oglądam filmy blu-ray filmy hd - porady - opisy gg - opisy - statusy do gg - pozycjonowanie i optymalizacja - Pozycjonowanie stron - Programy - systemy wymiany linków Systemy Wymiany Linków systemy wymiany linków - zdjęcia z gier

G:8,M:0,Y:38