PHP中写HTML

html-css04

PHP中写HTML,第1张

原:echo '<script>location.href="moban.php?id='.$arr['id'].'"</script>'

你还不懂单引号余双引号的区别,单引号内是不可以读取变量值的,双引号可以。

正确代码:

echo "<script>location.href='moban.php?$arr[id]'</script>"

不懂得可以追问

PHP文件里可以直接写HTML

比如

<?php

xxxx...

echo "<div>xxxx</div>"

?>

如下代码仅作为参考:

<?php

$html=<<<EOT

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns=" http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html charset=gb2312" />

<title></title>

</head><body>

<h1>EOT测试</h1>

</body>

</html>

EOTfile_put_contents("aa.html",$html)

?>