سلام
performance این دوتا کد خیلی فرق می کنه؟
performance این دوتا کد خیلی فرق می کنه؟
foreach($model->images as $image){ $imagine = (new Imagine())->open(Yii::$app->basePath . '/../all_assets/uploads/' . $img->name); $imagine->resize($imagine->getSize()->widen(200))->save(Yii::$app->basePath . '/../all_assets/uploads/thumb_' . $img->name); }// end of "foreach($model->images as $image)"
$obj = new Imagine(); foreach($model->images as $image){ $imagine = $obj->open(Yii::$app->basePath . '/../all_assets/uploads/' . $img->name); $imagine->resize($imagine->getSize()->widen(200))->save(Yii::$app->basePath . '/../all_assets/uploads/thumb_' . $img->name); }// end of "foreach($model->images as $image)"
no pain, no gain