標籤:

培神都開始學PHP了,你還在等什麼。

完了,讓你們這麼一搞培神已經對PHP大有興趣,目測《放棄PHP》已經在創作的途中了。

不過講道理,我說PHP臟可不是在黑他。他前輩Perl可是出了名「Quick & Dirty」的。而且,假如PHP真的能夠像Perl那樣有強一致性和規則的類型系統,我才不會這麼討厭他。

但是畢竟不是每個人都像Larry Wall那樣,既是個語言學家又是個計算機科學家。

聽說有人提到了PHP的數組(An array in PHP is actually an ordered map),我很開心,因為這忽然讓我覺得Brendan Eich好像沒那麼混蛋。

<?phpnn$hello = array();nn$hello []= 1; // YAY! array-append operator!nn$hello ["fuck"] = 2;nn$hello = array("idiot" => 4, "stupid" => 5, "hello" => $hello);nn$hello [100] = $hello; // what? no!nnprint_r($hello);nn// oh yes we have array literal now!nn$fuck = [1, 2, 3];nn$shit = [1 => 2, 3 => 4];nn// and you know what? object literal!n$obj = (object)["yes" => "this", "is" => "it"];nnprint_r([n $fuck,n $shit,n $obj->yes,n $obj->isn]);nn?>n

輸出結果:

Arrayn(n [idiot] => 4n [stupid] => 5n [hello] => Arrayn (n [0] => 1n [fuck] => 2n )nn [100] => Arrayn (n [idiot] => 4n [stupid] => 5n [hello] => Arrayn (n [0] => 1n [fuck] => 2n )nn )nn)nArrayn(n [0] => Arrayn (n [0] => 1n [1] => 2n [2] => 3n )nn [1] => Arrayn (n [1] => 2n [3] => 4n )nn [2] => thisn [3] => itn)n

推薦閱讀:

我應該選擇前端,還是繼續搞PHP?
從0開始學PHPExcel(1)之初探
為什麼 PHP 是最好的語言?現在是,將來也會是

TAG:PHP |