大佬教程收集整理的这篇文章主要介绍了如何编写 HTML 中的 PHP 代码,最后一个在 PHP 中?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是 php 新手,我想知道是否可以在 HTML 中编写 php 代码,最后一个是在 php 中。
例如在以下代码中:
$bodyHTML = '
<div class="container">
<img src="' . $bodyBACkground . '" class="imgBg"/>
<form method="POST" action="mapa-cardio.php" style="top:150px">
<input type="text" name="name" value="'. $name . '" class="transparent-input Font-size-name" style="top: 181px;left: 54px;wIDth: 294px;height: 28px;">
<input type="text" name="data1" value="'. $data1 . '" class="transparent-input Font-size-name" maxlength="2" style="top: 181px;left: 468px;wIDth: 19px;height: 28px;">
<input type="text" name="data2" value="'. $data2 . '" class="transparent-input Font-size-name" maxlength="2" style="top: 181px;left: 494px;wIDth: 19px;height: 28px;">
<input type="text" name="data3" value="'. $data3 . '" class="transparent-input Font-size-name" maxlength="4" style="top: 181px;left: 521px;wIDth: 33px;height: 28px;">
<!-- DADOS ANTROPOMÉTRICOS -->
<input type="text" name="altura" value="'. $altura . '" class="Font-size" style="top: 243px;left: 26px;wIDth: 26px;height: 10px;">
<input type="text" name="peso" value="'. $peso . '" class="Font-size" style="top: 267px;left: 26px;wIDth: 26px;height: 10px;">
<input type="text" name="perimetroabdominal" value="'. $perimetroabdominal . '" class="Font-size" style="top: 291px;left: 26px;wIDth: 26px;height: 10px;">
<!-- HÁBITOS -->
'if( isset($_POST['tabagismo']) ) {
$bodyHTML .= '<img src="' . $checkImage . '" class="check" style="top: 181px;left: 54px;wIDth: 15px;height: 15px;">';
}'
我想将该 php if 行添加到在 php 变量内连接的 HTML 中,这可能吗? 我收到以下错误:php 解析错误:语法错误,意外的“if”(T_IF)
任何帮助/建议将不胜感激。
你需要关闭第一个
$bodyHtml = '
<div class="container">
<img src="' . $bodyBACkground . '" class="imgBg"/>
<form method="POST" action="mapa-cardio.php" style="top:150px">
<input type="text" name="name" value="'. $name . '" class="transparent-input font-size-name" style="top: 181px;left: 54px;width: 294px;height: 28px;">
<input type="text" name="data1" value="'. $data1 . '" class="transparent-input font-size-name" maxlength="2" style="top: 181px;left: 468px;width: 19px;height: 28px;">
<input type="text" name="data2" value="'. $data2 . '" class="transparent-input font-size-name" maxlength="2" style="top: 181px;left: 494px;width: 19px;height: 28px;">
<input type="text" name="data3" value="'. $data3 . '" class="transparent-input font-size-name" maxlength="4" style="top: 181px;left: 521px;width: 33px;height: 28px;">
<!-- DADOS ANTROPOMÉTRICOS -->
<input type="text" name="altura" value="'. $altura . '" class="font-size" style="top: 243px;left: 26px;width: 26px;height: 10px;">
<input type="text" name="peso" value="'. $peso . '" class="font-size" style="top: 267px;left: 26px;width: 26px;height: 10px;">
<input type="text" name="perimetroabdominal" value="'. $perimetroabdominal . '" class="font-size" style="top: 291px;left: 26px;width: 26px;height: 10px;">';
<!-- HÁBITOS -->
if( isset($_POST['tabagismo']) ) {
$bodyHtml .= '<img src="' . $checkImage . '" class="check" style="top: 181px;left: 54px;width: 15px;height: 15px;">';
}
以上是大佬教程为你收集整理的如何编写 HTML 中的 PHP 代码,最后一个在 PHP 中?全部内容,希望文章能够帮你解决如何编写 HTML 中的 PHP 代码,最后一个在 PHP 中?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。