The beauty of string parsing part 2

Somebody suggested that I use apostrophes in my string parsing examples. Sure!

<?php
error_reporting
(E_ALL);
$array['test'] = "string used\n";
echo
"$array['test']";
echo
"{$array['test']}";
echo
"${array['test']}";
$array = array();
$array['test'][1] = "string used\n";
echo
"$array['test'][1]";
echo
"{$array['test'][1]}";
echo
"${array['test'][1]}";
?>

So what will happen?
Well, half of this is a syntax error. You need to comment out a few:
<?php
error_reporting
(E_ALL);
$array['test'] = "string used\n";
#echo "$array['test']";
echo "{$array['test']}";
echo
"${array['test']}";
$array = array();
$array['test'][1] = "string used\n";
#echo "$array['test'][1]";
echo "{$array['test'][1]}";
#echo "${array['test'][1]}";
?>

So... are you still sure the WTF comes from me omitting apostrophes? :p

Comments

Whaaat? Why are you

Whaaat? Why are you commenting lines with a hash instead of two slashes? That's the *real* WTF! How can you ignore PHP/Drupal coding standards so brazenly?!?!?!

:P

A hash? The Python dark side

A hash? The Python dark side got you too? :P

P.S.
I know it's valid, just an observation.

Totally glad I'm not the only

Totally glad I'm not the only one who has found herself commenting PHP with hashes.

It's valid syntax, why not use it? It's easier than // to type and pick out at a glance.

Infact all the alternate syntax that PHP gives you for uh.. everything is a WTF in and of itself.

bavabiaps

Unmappyaspels
Bweg
Dicsaspickeri
ywod

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