用<?php来表示php标识符的起始,然后放入php语句并通过加上一个终止标识符?>来退出php模式,可以根据自己的需要在html文件中像这样开启或关闭php模式。大多数的嵌入式脚本都是这样嵌入到html中并和html一起试用的,例如 css,javascript,php,asp一级jsp等
<!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=utf-8" />
<!-- 在Html 中使用style标记嵌入css脚本 -->
<style>
body{
margin:0px;
background:#ccc;
}
</style>
<title>第一个php</title>
</head>
<body>
<!-- 在html中试用script 标记嵌入javascript脚本 -->
<script>
alert("客户端的时间"+(new Date()));
</script>
<!-- 在html中使用一下标记嵌入php脚本 -->
<?php
echo "服务器时间".date("Y-m-d H:i:s")."<br>";
?>
</body>
</html>