1.例子程序
<html>
<head>
<title>demon</title>
</head>
<body>
<?php
echo "hello";
?>
</body>
</html>
2、查看所用浏览器
<html>
<head>
<title>firstdemon</title>
</head>
<body>
<?php
echo $_SERVER["HTTP_USER_AGENT"];
?>
</body>
</html>
3、strpos查找字符
<?php
if(strpos($_SERVER["HTTP_USER_AGENT"],"hrom")!==false){
?>
<h3>strpos must have returned non-false</h3>
<center><b>you are using internet</b></center>
<?php
}else{
?>
<h3>strpos must have returned false</h3>
<center><b>you are not using internet</b></center>
<?php
}
?>
4、form表单
<form action="action.php" method="POST">
Your name: <input type="text" name="name" />
Your age: <input type="text" name="age" />
<input type="submit">
</form>
自动全局变量
Welcome <?php echo $_POST["name"]; ?>.<br/>
you are <?php echo $_POST["age"]; ?>years old.
6、从HTML中分离
<?php
if (1) {
?>
<strong>This is true.</strong>
<?php
} else {
?>
<strong>This is false.</strong>
<?php
}
?>
7、“单行”注释仅仅注释到行末或者当前的 PHP 代码块,视乎哪个首先出现。
<h1>This is an <?php # echo "simple";?> example.</h1>