note 119890 added to language.oop5.magic

From: Date: Thu, 15 Sep 2016 19:04:45 +0000
Subject: note 119890 added to language.oop5.magic
Groups: php.notes 
Request: Send a blank email to php-notes+get-206595@lists.php.net to get a copy of this message
PHP 7+ solves a problem with __invoke noted about 4 yrs ago: <?php class a { function __construct() { } function __invoke() { echo("Invoked\n"); } } $a = new a(); $a(); // Output: Invoked class b { private $x; function __construct() { $this->x = new a(); ($this->x)(); // Works in PHP 7+ // $this->x(); // Will blow up in your face: undefined method b::x } } $b = new b(); // Output: Invoked ---- Server IP: 72.52.91.14 Probable Submitter: 209.33.217.66 ---- Manual Page -- http://php.net/manual/en/language.oop5.magic.php Edit -- https://master.php.net/note/edit/119890 Del: integrated -- https://master.php.net/note/delete/119890/integrated Del: useless -- https://master.php.net/note/delete/119890/useless Del: bad code -- https://master.php.net/note/delete/119890/bad+code Del: spam -- https://master.php.net/note/delete/119890/spam Del: non-english -- https://master.php.net/note/delete/119890/non-english Del: in docs -- https://master.php.net/note/delete/119890/in+docs Del: other reasons-- https://master.php.net/note/delete/119890 Reject -- https://master.php.net/note/reject/119890 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206595) next »