International PHP Conference Munich 2025

Voting

: zero plus zero?
(Example: nine)

The Note You're Voting On

herebepost (ta at ta) [iwonderr] gmail dot com
8 years ago
While not relevant in everyday PHP programming, it seems to be possible to insert whitespace and comments between the dollar signs of a variable variable. All three comment styles work. This information becomes relevant when writing a parser, tokenizer or something else that operates on PHP syntax.

<?php

$foo
= 'bar';
$

/*
I am complete legal and will compile without notices or error as a variable variable.
*/
$foo = 'magic';

echo
$bar; // Outputs magic.

?>

Behaviour tested with PHP Version 5.6.19

<< Back to user notes page

To Top