3 ms·
If PHP scoped to blocks, it would be less of an issue, you could just wrap your procedural code in curly braces and call it a day { $foo = 'bar'; /
by donatj 1y ago
If PHP scoped to blocks, it would be less of an issue, you could just wrap your procedural code in curly braces and call it a day
{
$foo = 'bar'; // only defined in this block
}
I use this reasonably often in Go, I wish it were a thing in PHP. PHP allows blocks like this but they seem to be noops best I can tell.