PHP 解析错误:语法错误,第 13 行的 /root/Desktop/generator/dump.php 中出现意外


PHP Parse error: syntax error, unexpected T_VARIABLE in /root/Desktop/generator/dump.php on line 13

我的问题是我不明白为什么它实际上不起作用?我也是PHP的新手,所以我正在学习这个PHP。我不知道为什么这是一个意想不到的T_VARIABLE,我假设它的意思是" $"

<?php
   include('database.class.php');
   $sql = new Database(NULL);
   $ids = $sql->select('*', '`ids` ORDER BY `UserId` ASC', NULL, NULL, NULL, true, true);
   $dump = array();
   foreach($ids as $index=>$id);
        $dump[] = $id['UserId'].' | REGLINK - http://xat.com/web_gear/chat/register.php?UserId='.$id['UserId'].'&k2='.$id['k2'].'&mode=1'
   $DumpFile= 'ids.txt';
   if(file_exists($DumpFile)) {
        unlink($DumpFile);
   }
   file_put_contents($DumpFile, implode("'r'n", $dump));
   die(count($dump).' ids were dumped into the list.'."'n");
?>

你必须在 &mode=1' 之后加上分号喜欢:

$ids = $sql->select('*', '`ids` ORDER BY `UserId` ASC', NULL, NULL, NULL, true, true);
$dump = array();
foreach($ids as $index=>$id);
        $dump[] = $id['UserId'].' | REGLINK - http://xat.com/web_gear/chat/register.php?UserId='.$id['UserId'].'&k2='.$id['k2'].'&mode=1';
$DumpFile= 'ids.txt';
if(file_exists($DumpFile)) {
        unlink($DumpFile);
}
file_put_contents($DumpFile, implode("'r'n", $dump));
die(count($dump).' ids were dumped into the list.'."'n");
?>