HN user

jblotus

132 karma
Posts7
Comments14
View on HN

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

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,

author here, it wasn't about hiding private variables. i was demonstrating using closures to avoid global namespace collisions which i think is generally a big problem for beginners.