html使用php参数

同一个php文件下,php中定义的参数在html标签内如何使用
<?php
$id = 3;
?>

<form id="form1" name="form1" method='post' action='add.php?id='+$id>
这样获取不到值呢
格式不对吗

<?php
    $id=3;
    echo "<form id='form1' name='form1' method='post' action='add.php?id=$id'>";
    //或
    echo '<form id="form1" name="form1" method="post" action="dd.php?id=
'.$id.'">';
?>    
    //或
  <form id="form1" name="form1" method="post" action="add.php?id=<?php echo $id;?>">

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-03-21
你这个是html文件还是php文件,如果是html文件,那么你这样定义是没用的,因为这个是php代码,在服务器那边执行的,html是客户端的,静态的。
第2个回答  2014-03-21
<form id="form1" name="form1" method='post' action='add.php?id=<?=$id?>'>
第3个回答  2014-03-21
这样<form id="form1" name="form1" method='post' action='add.php?id='+<?php echo $id;?>>
第4个回答  2014-03-21
<form id="form1" name="form1" method='post' action='add.php?id='<php>echo 3;</php>>
相似回答