彙總系列會堅持持續更新,時間有限的話會先記錄相關內容,後期完善具體,只有點滴積累才能厚積薄發!
php的閉包(Closure)也就是匿名函數php
$a =function()use($b) { }
public function getContents() { $subject = $this->articleContent->content; return preg_replace_callback_array( [ '/\bid\b\s*=\s*[\'\"]?([^\'\"]*)[\'\"]?/i' => function ($match) { $id = $match[0]; $id = explode('=', $id)[1]; $id = preg_replace('/\'/', '', $id); $data = ArticleImage::find()->where(['id'=>$id])->select('path')->scalar(); return "src='{$data}'"; }, ], $subject ); }
// 獲取13位時間戳 private static function getMillisecond(){ list($t1, $t2) = explode(' ', microtime()); return sprintf('%.0f',(floatval($t1)+floatval($t2))*1000); }