我正在使用PHP 7.1.33和"fabpot/goutte": "^3.2"。
运行以下脚本时,我得到以下信息:
PHP Warning: array_push() expects parameter 1 to be array, null given in C:\Users\testFile.php on line 88
PHP Stack trace:
PHP 1. {main}() C:\Users\testFile.php:0
PHP 2. updateCalendarDetailsData() C:\Users\testFile.php:104
PHP 3. Symfony\Component\DomCrawler\Crawler->each($closure = *uninitialized*) C:\Users\testFile.php:99
PHP 4. {closure:C:\Users\testFile.php:31-99}($node = *uninitialized*, *uninitialized*) C:\Users\Desktop\Code\vendor\symfony\dom-crawler\Crawler.php
:368
PHP 5. Symfony\Component\DomCrawler\Crawler->each($closure = *uninitialized*) C:\Users\testFile.php:90
PHP 6. {closure:C:\Users\testFile.php:53-90}($LEFT_TD = *uninitialized*, *uninitialized*) C:\Users\Desktop\Code\vendor\symfony\dom-crawler\Crawler.
php:368
PHP 7. array_push(*uninitialized*, *uninitialized*) C:\Users\testFile.php:88
我正在运行以下脚本:
<?php
require 'vendor/autoload.php';
use Goutte\Client;
use Symfony\Component\DomCrawler\Crawler;
function updateCalendarDetailsData()
{
$client = new Client();
$x = 1;
$LIMIT = 3;
global $x;
global $LIMIT;
$x++;
$res1Array = array();
$ffUrlArr = ["https://www.forexfactory.com/calendar.php?month=Jan2020"];
foreach ($ffUrlArr as $key => $v) {
try {
$crawler = $client->request('GET', $ffUrlArr[$key]);
} catch (\Exception $ex) {
error_log($ex);
}
$TEMP = array();
$count = $crawler->filter('.calendar_row')->count();
$i = 1; // count starts at 1
$crawler->filter('.calendar_row')->each(function ($node) use ($count, $i) {
$EVENT = array();
global $res1Array;
$EVENTID = $node->attr('data-eventid');
有什么建议为什么我会收到警告?
感谢您的回复!
牧羊人nacy