Re: [RFC][Discussion] use construct (Block Scoping)
| From: | Tim Düsterhus | Date: | Tue, 04 Nov 2025 08:50:19 +0000 |
| Subject: | Re: [RFC][Discussion] use construct (Block Scoping) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129064@lists.php.net to get a copy of this message | ||
Hi
Am 2025-11-04 07:08, schrieb Bruce Weirdan:
What would happen to the variables introduced in the statements
block, rather than in use()? Will they still be available outside of the
block?
Yes. The construct only affects the variables listed in the “declaration list”. I have adjusted the “simple example” to introduce a new variable $z that is initially defined in the block, but not listed in the declaration list to make that clearer.
That is a syntax error (unexpecteduse () { $number = 42; } var_dump($number); // what happens here?Also, is an empty list of vars inuse(as in the example above) allowed?
)).
Best regards
Tim Düsterhus