Home >Backend Development >PHP Problem >How to combine php with html
PHP and HTML have many interactions: PHP can generate HTML, and HTML can pass information to PHP.
## 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!