2006/5/2, Richard Lynch <ceo@xxxxxxxxx>:
Does anybody have a rational explanation for what purpose in life the following syntax is considered acceptable? <?php $query = "UPDATE whatever SET x = 1"; $query; ?> Note that the line with just $query; on it doesn't, like, "do" anything. I suppose in a Zen-like sort of way, it "exists" and all, but, really, what's the point? Is there some subtle reason for this not being some kind of syntax error that's way over my head or something? This is not just philosophical minutiae -- Real-world beginners, with no programming experience, actually type the above (albeit with a lot more logic and whatnot in between) and then wonder why the query didn't execute. It even makes a wild sort of sense to type that, if you presume that a beginner might not grasp the distinctions between PHP and MySQL and the relationship yet. Does anybody actually USE this idiom in any meaningful way? <?php "string"; ?> -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/ ) To unsubscribe, visit: http://www.php.net/unsub.php
I believe this is just C syntax legacy, although I think you can pass an argument to a C compiler to raise a warning when this kind of statements are found, that can't be done in PHP. Anyway, is just the way compiler/interpreters are made when a language has a C syntax style, it's just more efficient for the compiler to do what you're told and don't ask too many questions (if you mess up and your program is slow or buggy is your fault not the compiler's).