【发布时间】:2018-06-05 17:12:41
【问题描述】:
我尝试了一些帖子,但没有任何东西可以解决我的错误,有人可以看到我哪里出错了吗? 它显示:致命错误:无法重新声明 connectt()(之前在
中声明<?php
$jsonContents = file_get_contents('data/data.json');
$data_array = json_decode($jsonContents, true);
foreach($data_array as $key=> $value) {
$domain = $value['domain'];
function connectt($domain, $port, $timeOut = 5)
{
$fp = fsockopen($domain, $port, $errno, $errstr, $timeOut);
if (!$fp) {
$jsonContents = file_get_contents('data/data.json');
$data_array = json_decode($jsonContents, true);
foreach ($data_array as $key => $value) {
$domain = $value['domain'];
$data_array = json_decode($jsonContents, true);
$jsonContents = file_get_contents('data/data.json');
if ($value['domain'] == $domain) {
$data_array[$key]['ssl'] = "Not Valid";
}
};
$json = json_encode($data_array);
file_put_contents('data/data.json', $json);
} else {
$jsonContents = file_get_contents('data/data.json');
$data_array = json_decode($jsonContents, true);
foreach ($data_array as $key => $value) {
$domain = $value['domain'];
$jsonContents = file_get_contents('data/data.json');
$data_array = json_decode($jsonContents, true);
if ($value['domain'] == $domain) {
$data_array[$key]['ssl'] = "Valid";
}
$json = json_encode($data_array);
file_put_contents('data/data.json', $json);
}
}
}
$port = 443;
connectt($domain, $port);
}
【问题讨论】:
-
函数声明应该在foreach循环之外
标签: php