note 126779 added to language.variables.scope

From: Date: Wed, 19 Jan 2022 14:37:21 +0000
Subject: note 126779 added to language.variables.scope
Groups: php.notes 
Request: Send a blank email to php-notes+get-217517@lists.php.net to get a copy of this message
Declaring a variable to be global in a function call argument will cause a parse error. RIGHT: <?php $a = 1; // global scope function test() { global $a; echo subtest($a); // works } function subtest($argument) { return $argument + 1; } test(); ?> WRONG: <?php $a = 1; // global scope function test() { echo subtest(global $a); // results in parse error } function subtest($argument) { return $argument + 1; } test(); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 23.120.180.81) ---- Manual Page -- https://php.net/manual/en/language.variables.scope.php Edit -- https://main.php.net/note/edit/126779 Del: integrated -- https://main.php.net/note/delete/126779/integrated Del: useless -- https://main.php.net/note/delete/126779/useless Del: bad code -- https://main.php.net/note/delete/126779/bad+code Del: spam -- https://main.php.net/note/delete/126779/spam Del: non-english -- https://main.php.net/note/delete/126779/non-english Del: in docs -- https://main.php.net/note/delete/126779/in+docs Del: other reasons-- https://main.php.net/note/delete/126779 Reject -- https://main.php.net/note/reject/126779 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217517) next »