0
$test=1;
{
    $test=2;
}
var_dump($test);

The output of this is 2. I would have expected 1?

What is the point of these curly braces? Do they have some special usage, or it's just allowed syntax that doesn't cause parsing error?

Dalius
  • 726
  • 1
  • 8
  • 19

1 Answers1

6

PHP does not support variable scoping using braces (or any other syntax elements). They are just doing nothing in your example.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266