Home > Article > Backend Development > Detailed explanation of three ways to write nested HTML in PHP
Generally speaking, there are two mixed writing methods, one is HTML with PHP, written
; the other is PHP sets HTML and writes
. If PHP enables short tag writing, it can also be written as
=$item['RAND']?>
. There is also a different way Commonly used mixed writing methods are as follows:
easy way to execute conditional html / javascript / css / other language code with php if else:
html code to run if condition is true
html code to run if condition is false
List two ways of writing a piece of code in the project:
if($resitem['PREVIEW']){
echo $resitem['PREVIEW'];
} else {
echo "static/images/bg72.png";
}
?>
Writing method two:
if($resitem['PREVIEW']): ?> =$resitem['PREVIEW']?>static/images/bg72.png
The summary is complete; thank you all for reading, I hope you will benefit from it.
For more information, please refer to the official document http://www.php.net/manual/zh/control-structures.if.php
This article is reproduced from: https://blog.csdn. net/freshlover/article/details/9279527
Recommended tutorial: "php tutorial"
The above is the detailed content of Detailed explanation of three ways to write nested HTML in PHP. For more information, please follow other related articles on the PHP Chinese website!