【发布时间】:2023-03-12 22:35:02
【问题描述】:
我不太确定我到底做错了什么,我确实检查了其他问题,我推断出的只是返回(称为“空”的东西)只支持变量,尽管那没有'并没有真正改变任何东西。
当我运行它时,我的代码中出现了一个非常奇怪的错误,并且无法确定它的头或尾。
Fatal error: Can't use function return value in write context in /home/shortcu1/public_html/projects/friendcodes/newUser.php on line 103
这是被调用的主要函数。 (在一个名为 newUser.php 的文件中)
function isBumping($forumid, $username, $premium){
if($premium == 'true'){
$file = file_get_contents('plist.txt'); // This is the file I'm testing on
echo 'Running code as premium<br>';
} else {
$file = file_get_contents('list.txt');
}
$forumid = $forumid.':'.$username;
$posts = explode(' ', $file);
$posts ($info, $bump) = array_filter($posts, function($item) use ($forumid, $posts){
// This will check for matching forum ID
if(strpos($item, $forumid) !== true){
$pos = strpos($item, ':Day-');
$pos = $pos + 5;
$day = (int) substr($item, $pos, 1); // Converts the stored date to a numerical value. remember 1 = monday, 7 = sunday
$today = date('N');
$bump = false;
if(($day+3) % 7 > $today){
// Old enough to re-bump
return array ($item, $bump);
} else {
// Too recent to re-bump
$bump = true;
return array ($item, $bump);
}
}
});
print_r($posts[1]);
echo '<br>';
print_r($posts[2]);
}
它正在通过文件 test.php 运行:
include('newUser.php');
isBumping(1, 'Spitfire', 'true')
名为plist.txt的文件如下:
1:Spitfire:Day-4:8JX-UKR8:8JX-UKR8:Spirit:90 1:喷火:Day-4:8JX-UKR8:8JX-UKR8:Spirit:90 1:喷火:Day-4:8JX-UKR8:8JX-UKR8:Spirit:90 1:喷火:Day-4:8JX-UKR8:8JX-UKR8:Spirit:90
【问题讨论】: