错误,回显形式为预期的逗号或分号

时间:2019-04-18 18:07:47

标签: php html5

我试图回显包含更多php的表单。我收到错误消息,期望逗号或分号。

有人可以帮我吗?

echo "<html><body><form action="index.php?tagid="'.$tagid.'" method="post">edit scanned tag's value<input type="text" name="tagvalue"><br><input type="submit" value="<?php $file = fopen("myfile.json","a"); $tagval = json_decode($json); echo $tagval->{'tagid'}; fclose($file); ?>"></form></body></html>";

1 个答案:

答案 0 :(得分:0)

您的回声内部包含未转义的qout。试试这个

$file = fopen("myfile.json","a"); 
$tagval = json_decode($json); 
fclose($file); 
echo '<html><body><form action="index.php?tagid="'.$tagid.'" method="post">edit scanned tag\'s value<input type="text" name="tagvalue"><br><input type="submit" value="'.$tagval->{'tagid'}.'"></form></body></html>';

或者您可以编写如下内容

<?php
$file = fopen("myfile.json","a"); 
$tagval = json_decode($json); 
fclose($file); 
?>
<html>
    <body>
      <form action="index.php?tagid="<?php echo $tagid; ?>" method="post">edit scanned tag's value
        <input type="text" name="tagvalue"><br>
        <input type="submit" value="<?php echo $tagval->{'tagid'};?>">
      </form>
    </body>
</html>