나는 아래의 html 양식을 가지고 php 파일 (workcard_done.php)에 제출합니다. 내 문제는 코드를 제출할 때입니다. else echo "nothing here";
isset에서 not (!) 연산자를 설정하면 원하는 결과를 얻을 수 있습니까? 그것은 if(isset($_POST['submit']) && !empty($_POST['submit']))
와 함께 잘 작동합니다.
누구나 저를 미치게 만드는 아래 코드를 잘못 설명 할 수 있습니까?
<!DOCTYPE html>
<HTML>
<head>
<title>yoyo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form action="workcard_done.php" name="workCard_open" method="POST">
<br>
<table>
<tr>
<th>title 1</th>
<th>title 2</th>
</tr>
<tr>
<td><input type="text" name="name[]" value="" ></td>
<td><input type="text" name="price[]" value="" class="matr_price"/></td>
</tr>
<tr>
<td><input type="text" name="name[]" value="" ></td>
<td><input type="text" name="price[]" value="" class="matr_price"/></td>
</tr>
<tr>
<td>Total incl. VAT:</td>
<td><span type="text" name"sum[]" id="sum">0</span></td>
</tr>
</table>
<input type="submit" name"submit" class="submit" value="Done"/>
</form>
</body>
</html>
workcard_done.php
<!DOCTYPE html>
<html>
<head>
<title>title...</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<pre>
<?php
error_reporting(E_ALL);
if(isset($_POST['submit']) && !empty($_POST['submit'])) {
$name = $_POST['name'];
$price = $_POST['price'];
$user = $_POST['user'];
print_r($name);
echo "<br>";
print_r($price);
echo "<br>";
print_r($user);
echo "<br>";
}
else {
echo "nothing here";
}
?>
</pre>
</body>
</html>
는 isset에없는 (!) 연산자를 설정하면, 나는 아래 결과를 원 얻는다.
Array
(
[0] => slange
[1] => rfd
)
Array
(
[0] => 123
[1] => 200
)
Array
(
[user] => 2
)
'! isset ($ _ POST [ 'submit']) &&! empty ($ _ POST [ 'submit'])'은 항상 FALSE로 평가됩니다. '$ _POST [ 'submit']'이 설정되어 있지 않으면 빈 상태가되고'! empty()'는 FALSE로 평가됩니다. 설정되면'! isset()'은 FALSE로 평가됩니다. 각 식에서 완전한 식은'거짓 '입니다. – axiac