Home > Backend Development > PHP Tutorial > Detailed explanation of three ways to write nested HTML in PHP

Detailed explanation of three ways to write nested HTML in PHP

烟雨青岚
Release: 2023-04-09 08:14:02
forward
4088 people have browsed it

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

<?php  ?><br>
Copy after login

; the other is PHP sets HTML and writes

<?php echo ?><br>
Copy after login

. If PHP enables short tag writing, it can also be written as

<?=$item[&#39;RAND&#39;]?><br>
Copy after login

. 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:<br><?php if (condition):?><br>html code to run if condition is true<br><?php else: ?><br>html code to run if condition is false<br><?php endif ?><br>
Copy after login

List two ways of writing a piece of code in the project:

<?php <br/>if($resitem[&#39;PREVIEW&#39;]){<br/>echo $resitem[&#39;PREVIEW&#39;];<br/>} else {<br/>echo "static/images/bg72.png";<br/>}<br/>?><br>
Copy after login

Writing method two:

<?php <br/>if($resitem[&#39;PREVIEW&#39;]): ?> <?=$resitem[&#39;PREVIEW&#39;]?><?php else: ?>static/images/bg72.png<?php endif ?><br>
Copy after login

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!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template