Variable names

A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

Compare to:

<?php
$a
= 1;
$
$a = 'foo';
print ${
1};
?>

So the restriction that the variable name can not start with a number is only enforced by the parser and even then it's fairly easy to circumvent. Maybe it would have been simpler to explain and implement if the definition would be "A valid variable name contains any number of letters, numbers, or underscores".

Comments

Your suggestion?

Would you rather see variables not starting with numbers at all, or allowing variables starting with numbers by the parser as well?

given the state of affairs

add numbers to the parser. it will be a wtf too ($123 looks fun) but a lot smaller wtf.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options