Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is this program valid?

Tags:

php

Reading this fascinating question made me remember a code snippet I stumbled across a few weeks ago; it gave me quite a few minutes of confusion until I figured out why it works, maybe it will be interesting for others as well.

<?php

http://example.com/some-article
$items = get_items();
// etc.

Obviously the programmer wanted to add an explanatory link as a comment before the code block, but forgot to add the // to the beginning. Nevertheless, the code works fine. Can you tell why?

like image 803
Tgr Avatar asked Aug 15 '12 21:08

Tgr


1 Answers

The http: is a goto label, and the rest of the line is commented out.

like image 140
Brandon Dusseau Avatar answered Nov 15 '22 11:11

Brandon Dusseau