Re: Syntax Oddity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Lynch schrieb:
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;
?>

Well from PHPs point of view this is not a syntax error.

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?

There is none :)

Is there some subtle reason for this not being some kind of syntax
error that's way over my head or something?

Why should it be a syntax error?
You can do the same stuff in nearly every programming language besides PHP.
It's just useless.
The languages doesn't decide between usless and not useless.
Just between syntax okay and not okay.


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";
?>
Well i don't ;P

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux