博客 / 列表

小小心 - php中Generator的執行過程

説到php中的Generator(生成器),有人可能會想到協程,這裏我們先不説php如何實現協程,我們探究下Generator的執行過程。 Generator是通過yield實現,yield 關鍵字是php5.5版本推出的一個特性。 首先,看下面的代碼: function gen(){   while(true){

php , yield