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 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
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.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: handle in /in/QZeg2 on line 3 Warning: fgetcsv() expects parameter 1 to be resource, null given in /in/QZeg2 on line 3 Warning: count(): Parameter must be an array or an object that implements Countable in /in/QZeg2 on line 5 Notice: Undefined variable: fieldsCount in /in/QZeg2 on line 5 Fatal error: Uncaught Error: Using $this when not in object context in /in/QZeg2:7 Stack trace: #0 {main} thrown in /in/QZeg2 on line 7
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Warning: fgetcsv() expects parameter 1 to be resource, null given in /in/QZeg2 on line 3 Warning: count(): Parameter must be an array or an object that implements Countable in /in/QZeg2 on line 5 Fatal error: Uncaught Error: Using $this when not in object context in /in/QZeg2:7 Stack trace: #0 {main} thrown in /in/QZeg2 on line 7
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Notice: Undefined variable: handle in /in/QZeg2 on line 3 Warning: fgetcsv() expects parameter 1 to be resource, null given in /in/QZeg2 on line 3 Notice: Undefined variable: fieldsCount in /in/QZeg2 on line 5 Fatal error: Uncaught Error: Using $this when not in object context in /in/QZeg2:7 Stack trace: #0 {main} thrown in /in/QZeg2 on line 7
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Notice: Undefined variable: handle in /in/QZeg2 on line 3 Warning: fgetcsv() expects parameter 1 to be resource, null given in /in/QZeg2 on line 3 Notice: Undefined variable: fieldsCount in /in/QZeg2 on line 5 Fatal error: Using $this when not in object context in /in/QZeg2 on line 7
Process exited with code 255.

preferences:
263.84 ms | 402 KiB | 327 Q