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.

```php
use () {
  $number = 42;
}
var_dump($number); // what happens here?
```

Also, is an empty list of vars in `use` (as in the example above) allowed?

That is a syntax error (unexpected `)`).

Best regards
Tim Düsterhus

Reply via email to