当我尝试启动 PHP 脚本时,出现此错误:
[错误] [客户端 ::1] PHP 解析错误:语法错误,/var/www/loterija.php 第 16 行出现意外的 T_VARIABLE
我认为问题出在
split()
函数上。这是代码:
<?php
$arr = array();
if (isset($_POST['roll'])):
echo "Lucky numbers: " . '<br />';
for ($i = 1; $i <= 5; $i++) {
$arr[] = rand(1, 100);
}
$post = $_POST['numbers'];
echo '<br />' . "Your numbers: " . '<br />';
$split = split(" ", $post, 5);
endif;
?>
<html>
<head>
<title>Lottery Script</title>
</head>
<body>
<form action="#" method="post">
Enter five numbers: <input type="text" name="numbers" />
<input type="submit" name="roll" value="Roll!" />
</form>
</body>
</html>
拆分已弃用,请使用爆炸。您使用什么版本的 PHP。如果是5.0以上就用explode。
我假设你们被空间分开了。
没有理由使用
split()
,它已被弃用。$split = explode(" ", $post);