3v4l.org

run code in 300+ PHP versions simultaneously
<?php while (($peopleData = fgetcsv($handle, 1000, ",")) !== FALSE) { // echo count($peopleData) . ' - '. $fieldsCount; exit; if (count($peopleData) == $fieldsCount) { $attributes = array_combine(array_merge($this->fileUploadFields, $customColumns), $peopleData); $attributes = $this->formatAttributes($attributes); $model = null; if (null != $attributes['firstName'] && null != $attributes['lastName'] && null != $attributes['dateOfBirth']) { $model = User::model()->findByAttributes(array('firstName' => $attributes['firstName'], 'lastName' => $attributes['lastName'], 'dateOfBirth' => $attributes['dateOfBirth']), 'userType NOT IN ("' . User::POLITICIAN . '")'); } if (null == $model && null != $attributes['email']) { $model = User::model()->findByAttributes(array('email' => $attributes['email']), 'userType NOT IN ("' . User::POLITICIAN . '")'); } // Check Email contact limit if (!empty($attributes['email']) && $tc->packageInfo['totalEmailContacts'] < $emailContactsCount) { $this->isEmailContactLimitExceed = true; break; } if ($model == null) { $model = new User; $model->joinedDate = date('Y-m-d H:i:s'); $model->userType = User::SUPPORTER; $customFields = CustomValue::model()->getCustomData(CustomType::CF_PEOPLE, 0, CustomField::ACTION_CREATE, $attributes, CustomType::CF_SUB_PEOPLE_BULK_INSERT); } else { if ($model->userType != User::NON_SUPPORTER) { $model->userType = User::SUPPORTER; } $customFields = CustomValue::model()->getCustomData(CustomType::CF_PEOPLE, $model->id, CustomField::ACTION_CREATE, $attributes, CustomType::CF_SUB_PEOPLE_BULK_INSERT); } $model->scenario = 'bulkPeople'; $model->attributes = $attributes; $model->countryCode = $this->countryCode; $model->isManual = 1; $oldKeywords = $model->keywords; $model->keywords = empty($this->keywords) ? $oldKeywords : $this->keywords; $model->delStatus = User::NOTDELETE; $model->supporterDate = date('Y-m-d H:i:s'); $customErrors = array(); foreach ($attributes as $key => $val) { foreach ($customFields as $k => $customField) { if ($key == $customField->fieldName) { $customField->fieldValue = $val; $customValues[$customField->fieldName] = $val; $customField->validate(); $customErrors[] = $customField->errors; } } } $attributes = array_merge($model->attributes, $customValues); try { $valid = $model->validate(); $valid = CustomField::validateCustomFieldList($customFields) && $valid; if ($valid && $model->saveWithCustomData($customFields, null, false)) { $this->bulkSuccessCount++; if (!empty($model->email)) { $emailContactsCount++; } Yii::app()->appLog->writeLog("People created. People data:" . @json_encode($attributes)); $fbModule = FbProfile::model()->findByAttributes(array('userId' => $model->id)); if ($fbModule != null) { Feed::model()->updateFeedUserType($fbModule->fbUserId, $model->userType); } $twModule = TwProfile::model()->findByAttributes(array('userId' => $model->id)); if ($twModule != null) { Feed::model()->updateFeedUserType($twModule->twUserId, $model->userType); } } else { $errorKey = array_keys($model->errors); if (empty($model->errors)) { $errorKey = array_keys(current(array_filter($customErrors))); $firstElement = current(array_filter($customErrors)); $errorMsg = $firstElement[$errorKey[0]][0]; } else { $errorMsg = $model->errors[$errorKey[0]][0]; } Yii::app()->appLog->writeLog("People create failed. People data:" . @json_encode($attributes)); $this->fileErrors[] = Yii::t('messages', 'Failed,') . $errorMsg . "," . implode(",", $peopleData); } } catch (Exception $e) { Yii::app()->appLog->writeLog("People create failed. Error:{$e->getMessage()}"); } } else { Yii::app()->appLog->writeLog("People create failed. Data line:" . @json_encode($peopleData)); $this->fileErrors[] = Yii::t('messages', 'Failed, Number of data fields not match.') . "," . implode(",", $peopleData); } } fclose($handle);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $handle in /in/QZeg2 on line 3 Fatal error: Uncaught TypeError: fgetcsv(): Argument #1 ($stream) must be of type resource, null given in /in/QZeg2:3 Stack trace: #0 /in/QZeg2(3): fgetcsv(NULL, 1000, ',') #1 {main} thrown in /in/QZeg2 on line 3
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52.41 ms | 401 KiB | 8 Q