2013年12月9日 星期一

[PHP] dollar sign ($) 的陷阱

// == 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

[Java] Invalid HTTP method: PATCH

最近系統需要使用 Netty4,所以把衝突的 Netty3 拆掉,然後就出現了例外。 pom.xml <dependency> <groupId>com.ning</groupId> <artifactId>as...