;;;;$i = 123; ;;;;echo $i, PHP_EOL;
这段代码是否是很奇葩,使用;
做为代码缩进符号可是它是合法的语句,能够正常运行。而且在Java、PHP等语言中,均可以正常使用。php
我第一次得知这种写法,是上学时候,Java课老师告诉咱们的……性能
那么这么写除了脑残装B酷炫之外,它对性能是否有影响呢?code
<?php function test1($i) { if(0 === $i % 2) { return 1; } else { return 0; } } function test2($i) { ;;;;if(0 === $i % 2) { ;;;;;;;;return 1; } else { ;;;;;;;;return 0; } } $count = 10000000; $t = microtime(true); for($i = 0; $i < $count; ++$i) { test1($i); } echo 'test1: ', microtime(true) - $t, PHP_EOL; $t = microtime(true); for($i = 0; $i < $count; ++$i) { test2($i); } echo 'test2: ', microtime(true) - $t, PHP_EOL;
经过上面的代码运行得出,使用;
做为缩进符,会略慢于正常写法。io
因此,不要追求酷炫个性,而选择这种缩进方式哦!function