解析错误:语法错误,意外''(T_CONSTANT_ENCAPSED_STRING)

时间:2014-12-22 21:55:45

标签: php wget

我有这个用于在linux上运行wget的PHP代码

<?php

include 'theme.php';
ceklogin();
css();

if($_POST['wget-send'])
{
  $dir=$_POST['dir'];
  $link=$_POST['link'];
  exec('cd '.$dir,$out);
  exec('echo '.$link' > /tmp/wget-download-link.txt',$out);
  exec('wget -i /tmp/wget-download-link.txt -o /tmp/wget.log -c -t 100 -w 10',$out);
  echo $out[2];
  exit();
}

echo "<br><br><form action=\"".$PHP_SELF."\" method=\"post\">";
echo "Download directory :<br><input type=\"text\" name=\"dir\" size=\"15\" value=\"/mnt/usb/\"/><br>";
echo '<br>Download link :<br>';
echo "<textarea name=\"link\" rows=\"4\" cols=\"35\"></textarea><br><br>";
echo '<input type="submit" name="wget-send" value="Send" />';
echo "</form></div>";

foot();
echo '
</div>
</body>
</div>
</html>';

?>

当我尝试运行php时,它给了我这个错误:

Parse error: syntax error, unexpected '' > /tmp/wget-download-link.tx' (T_CONSTANT_ENCAPSED_STRING) in /www/wget.php on line 10

我哪里出错了?

3 个答案:

答案 0 :(得分:0)

在此行中缺少.

exec('echo '.$link.' > /tmp/wget-download-link.txt',$out);

答案 1 :(得分:0)

在此行.之后遗失$link

exec('echo '.$link.' > /tmp/wget-download-link.txt',$out);

答案 2 :(得分:0)

此网站不是您的基本语法调试错误,但无论如何你都去了。

exec('echo '.$link' > /tmp/wget-download-link.txt',$out);

您在.

之后错过了$link

应该是

exec('echo '.$link.' > /tmp/wget-download-link.txt',$out);