Class and object changes
instanceof, is_a(), is_subclass_of() and catch
In PHP 5.0, is_a() was deprecated and replaced by the
instanceof operator. There were some issues with the
initial implementation of instanceof, which relied on
__autoload() to search for missing classes.
If the class was not present, instanceof would throw
a fatal E_ERROR
due to the failure of
__autoload() to discover that class. The same behaviour
occurred in the catch operator and the
is_subclass_of() function, for the same reason.
None of these functions or operators call __autoload() in PHP 5.1.x, and the class_exists() workarounds used in code written for PHP 5.0.x, while not problematic in any way, are no longer necessary.
Abstract private methods
Abstract private methods were supported between PHP 5.0.0 and PHP 5.0.4, but were then disallowed on the grounds that the behaviours of private and abstract are mutually exclusive.
Access modifiers in interfaces
Under PHP 5.0, function declarations in interfaces were treated in exactly
the same way as function declarations in classes. This has not been the
case since October 2004, at which point only the public
access modifier was allowed in interface function declarations. Since
April 2005 - which pre-dates the PHP 5.0b1 release - the
static modifier has also been allowed. However, the
protected and private modifiers will
now throw an E_ERROR
, as will
abstract. Note that this change should not affect your
existing code, as none of these modifiers makes sense in the context of
interfaces anyway.
Changes in inheritance rules
Under PHP 5.0, it was possible to have a function declaration in a derived class that did not match the declaration of the same function in the base class, e.g.
This code will cause an E_STRICT
error to be emitted
under PHP 5.1.x.
<?php
class Base {
function &return_by_ref() {
$r = 1;
return $r;
}
}
class Derived extends Base {
function return_by_ref() {
return 1;
}
}
?>
Vertaling niet beschikbaar
De PHP-handleiding is nog niet in het Nederlands vertaald, dus het scherm is in het Engels. Als u wilt, kunt u het ook in het Frans of in het Duits raadplegen.
Als je de moed voelt, kun je je vertaling aanbieden ;-)
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 30/01/2003 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/php-rf-migration51.oop.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.