note 125709 added to functions.arrow

From: Date: Fri, 22 Jan 2021 02:04:20 +0000
Subject: note 125709 added to functions.arrow
Groups: php.notes 
Request: Send a blank email to php-notes+get-216215@lists.php.net to get a copy of this message
The variables in the enclosing scope captured by fn()'s body expression are ONLY the ones that it explicitly mentions, not every variable in the enclosing scope. <?php $inner = 42; $outer = 'inner'; $thunk_1 = fn($name) => $$name; $thunk_2 = fn() => $$outer; echo $thunk_1('inner'); echo $thunk_1($outer); echo $thunk_2(); ?> All of those calls will fail because $inner is undefined. ---- Server IP: 45.112.84.4 Probable Submitter: 101.0.109.162 (proxied: 125.239.154.159) ---- Manual Page -- http://php.net/manual/en/functions.arrow.php Edit -- https://master.php.net/note/edit/125709 Del: integrated -- https://master.php.net/note/delete/125709/integrated Del: useless -- https://master.php.net/note/delete/125709/useless Del: bad code -- https://master.php.net/note/delete/125709/bad+code Del: spam -- https://master.php.net/note/delete/125709/spam Del: non-english -- https://master.php.net/note/delete/125709/non-english Del: in docs -- https://master.php.net/note/delete/125709/in+docs Del: other reasons-- https://master.php.net/note/delete/125709 Reject -- https://master.php.net/note/reject/125709 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#216215) next »