note 81932 modified in migration5.incompatible by danbrown

From: Date: Sun, 03 Aug 2008 02:32:43 +0000
Subject: note 81932 modified in migration5.incompatible by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143075@lists.php.net to get a copy of this message
Three more that we discovered: == 1. No longer can re-assign $this == The follwoing example works under PHP4 (it outputs "OK"), but produces a fatal error under PHP5: <?php class a { var $text; function a() { $this->text = 'OK'; } } class b { var $text = 'NOT OK'; function b() { $this = new a(); } } $myClass = new b(); echo $myClass->text; ?> == 2. No comments allowed after shorthand echo block == The follwoing example works under PHP4, but produces a sytax error under PHP5. <?=//comment?> == 3. Constructors return a reference as default == The follwoing example works under PHP4, but produces an E_NOTICE notice under PHP5. <?php class MyClass { function MyClass() { echo('OK'); } } $myObj = null; $myObj &= new MyClass(); ?> Removing the ampersand solves the problem --was-- Three more that we discovered: == 1. No longer can re-assign $this == The follwoing example works under PHP4 (it outputs "OK"), but produces a fatal error under PHP5: <? class a { var $text; function a() { $this->text = 'OK'; } } class b { var $text = 'NOT OK'; function b() { $this = new a(); } } $myClass = new b(); echo $myClass->text; ?> == 2. No comments allowed after shorthand echo block == The follwoing example works under PHP4, but produces a sytax error under PHP5. <?=//comment?> == 3. Constructors return a reference as default == The follwoing example works under PHP4, but produces an E_NOTICE notice under PHP5. <? class MyClass { function MyClass() { echo('OK'); } } $myObj = null; $myObj &= new MyClass(); ?> Removing the ampersand solves the problem http://php.net/manual/en/migration5.incompatible.php

« previous php.notes (#143075) next »