You are right, they should both work. The reason the closure didn't work before was because of a stupid mistake on my side. I put some comment //this script is ... before <?php, which somehow messed up the script.