Heim  >  Artikel  >  Backend-Entwicklung  >  php怎么用$_post函数接收来自html中的表单的数据

php怎么用$_post函数接收来自html中的表单的数据

WBOY
WBOYOriginal
2016-08-23 09:17:481341Durchsuche

刚开始学习php 网上查了很多也不能用$_post函数打印出表单的数据
这是代码
HTML部分

<code>

<title>php test</title>
<meta charset="utf-8">

<form action="01.php" method="post" name="form1">
<table>
<tr>
    <td>fs</td>
    <td><input name="fs" type="text"></td>
    <td><input type="submit" value="提交"></td>
</tr>
</table>
</form>



PHP部分

<?php $fs=$_post['fs'];
echo $fs;
?>
按提交按钮后只能打印出php的代码</code>

回复内容:

刚开始学习php 网上查了很多也不能用$_post函数打印出表单的数据
这是代码
HTML部分

<code>

<title>php test</title>
<meta charset="utf-8">

<form action="01.php" method="post" name="form1">
<table>
<tr>
    <td>fs</td>
    <td><input name="fs" type="text"></td>
    <td><input type="submit" value="提交"></td>
</tr>
</table>
</form>



PHP部分

<?php $fs=$_post['fs'];
echo $fs;
?>
按提交按钮后只能打印出php的代码</code>

  • 确定表单action路径正确

  • phpPOST接收写法错误,要大写$_POST['fs'],你小写方式会被解析成一个变量

$_POST

大写。

php变量是区分大小写的,方法,函数名和常量不区分(但是仍然要求一致),需要像楼上这位朋友说的一样要大写,使用$_POST[],还有你说可以打印出php代码,我看应该不会的.

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn