Hacker News new | ask | show | jobs
by dleibovic 4904 days ago
I thought php was also function scope, not block scope as the author claims...?
1 comments

author here.

<?php $a = 1; /* global scope */

function test() { echo $a }

test();

in javascript, $a would be 1 but in PHP it is undefined and won't produce output,

after thinking about it for a while, I was misrepresenting what block scope actually was and removed those references in the post.