Home >Backend Development >PHP Problem >How to combine php with html

How to combine php with html

(*-*)浩
(*-*)浩Original
2019-09-29 11:47:389006browse

PHP and HTML have many interactions: PHP can generate HTML, and HTML can pass information to PHP.

How to combine php with html

## can be combined in a .php file. Both php code and html tags can be written in the php file.

The data transmitted in the background is simulated here (recommended learning:

PHP video tutorial)

<?php
$title = "这是一个标题";
$type = array("html","css","js","php");
$data = "这是一条数据";
$content = "这是内容";
?>
<!--这里是前端代码-->
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title><?php echo $title; ?></title>
</head>
<body>
<ul>
<?php foreach ($type as $value){echo "<li>$value</li>";} ?>
</ul>
<h1><?php echo $data; ?></h1>
<div><?php echo $content; ?></div>
</body>
</html>

The above is the detailed content of How to combine php with html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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