$ _POST ['str']我收到以下错误:
注意:第12行的C:\ Program Files\EasyPHP-5.3.8.0\www\strrev.php中的未定义索引:str
我花了太多时间为此寻找答案,但没有运气!请看一下代码,让我知道它有什么问题?
<html>
<head>
<title></title>
</head>
<body>
<?php
if (trim($_POST['str'])) {
$str = $_POST['str'];
$len = strlen($str);
for($i=($len-1); $i>=0;$i--) {
echo $str[$i];
}
} else {
?>
<form method="post" action="">
<input type="text" name="str" />
<input type="button" name="submit" value="Reverse" />
</form>
<?php
}
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
它显示错误旁边的文本字段和反向按钮.而且,当我按下按钮时,什么都不会发生.