我在HTML中有以下代码:
<input type ="text" name="<?php echo $id_global;?>"</input>
然后提交表单后,我尝试这样做,但它不工作:
$id_s = $_POST['$id_global'];
你需要去掉引号,
try $id_s=$_POST[$id_global];
去掉引号'
$id_s=$_POST[$id_global];
尝试使用双引号php将不考虑单引号之间的变量
<?php
$id_global = 'field_name';
?>
<form action="/Stackoverflow/index.php" name="testForm" method="POST">
<input type ="text" name="<?php echo $id_global;?>" />
</form>
<?php
if($_POST){
echo '<pre>';
print_r($_POST[$id_global]);
}
?>
根据需要编辑动作