// == case 1 == $foo = 'foo';$ $bar = 'bar'; // expect: $foo = 'foo', $bar = 'bar' // actual: $foo = 'foo', $bar = NULL // hint: PHP Notice: undefined variable: bar in test.php on line 4 // == case 2 == $foo = 'foo';$ bar = 'bar'; // actual: PHP Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$' in test.php on line 3 // == case 3 == $foo = 'foo';$ // actual: PHP Parse error: syntax error, unexpected $end, expecting T_VARIABLE or '$' in test.php on line 2
可以發現,在一些特定情形下,PHP 允許換行使用錢號 ($),但是不容易發現。 所以任何 PHP 的訊息應該都要注意。
PHP 5.3.24 (cli) (built: Jun 10 2013 16:42:20) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies with Xdebug v2.2.0rc1, Copyright (c) 2002-2012, by Derick Rethans