开发者

Problem with split()

when I try to launch my PHP script, I get this error: [error] [client ::1] PHP Parse error: syntax error, unexpected T_VARIABLE in /var/www/loterija.php on line 16

I think the problem is with split() function. Here's the code:

<?php

$arr = array();

if(isset($_POST['roll'])):

echo "Lucky numbers: " . '<br />';

for ($i = 1; $i <= 5; $i++) {
  开发者_如何学JAVA  $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>


Split is DEPRECATED, use explode. What version of PHP are you using. If it's 5.0 or above, use explode.

I am assuming you are separating by space.

http://php.net/manual/en/function.explode.php


There is no reason to use split() and it has been deprecated.
Just do this: $split = explode(" ", $post);


Consider preg_split or explode.

http://us.php.net/manual/en/function.split.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜