cookie 函数 session mail 数据库连接 xml
<?php
//写cookie
setcookie("user", "wang70937", time()+60);
//session
session_start();
if(isset($_session['views']))
$_session['views']=$_session['views']+1;
else
$_session['views']=1;
echo "session: views=". $_session['views']."<br />";
?>
<script >
function show(){
alert("asdf");
}
</script>
<html>
<title>php测试页面 </title>
<head><script src="clienthint.js"></script></head>
<body>
<?php
//输出
echo "<br />"."[******输出******]"."<br />";
echo "hello world!"."<br />";
$a = "php";
$b = "language";
echo $a." ".$b."<br />";
//数组
echo "<br />"."[******数组******]"."<br />";
$arr = array("abcde", "fghijk", "lmnopq");
foreach($arr as $value)
{
echo $value."<br />";
}
//函数
echo "<br />"."[******函数******]"."<br />";
function funa($a, $b){
echo "函数参数:".$a.", ".$b;
return "ret_value";
}
$ret = funa(123, "param");
echo "函数返回值:".$ret."<br />";
echo "<br />"."[******表单******]"."<br />";
?>
<form action="form.php" method="post">
name: <input type="text" name="name" />
age: <input type="text" name="age" />
<input type="submit" />
</form>
<?php echo "<br />";
echo "<br />"."[******上传文件******]"."<br />";
?>
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="submit" />
</form>
<?php
//session
echo "<br />"."[******session******]"."<br />";
//retrieve session data
echo "pageviews=". $_session['views'];
?>
<br />
<!-- //删除session -->
<?php
//echo "<br />"."[******删除session******]"."<br />";
// session_destroy();
?>
<?php
//发送邮件
echo "<br />"."[******发送邮件******]"."<br />";
$to = "wang70937@163.com";
$subject = "test mail";
$message = "hello! this is a simple email message.";
$from = "wang70937@gmail.com";
$headers = "from: $from";
mail($to,$subject,$message,$headers);
echo "mail sent."."<br />";
?>
<?php
//mysql教程数据库教程
echo "<br />"."[******mysql数据库******]"."<br />";
$con = mysql_connect("localhost","root","1");
if (!$con)
{
die('could not connect: ' . mysql_error());
}
else
echo "连接mysql成功!"."<br />";
mysql_select_db("bbs", $con);
mysql_query("set names gbk");
//show tables
$tablecount = mysql_query("show tables");
while($table = mysql_fetch_array($tablecount))
{
//表名
$tablename = $table[0];
$sql = "select * from ".$tablename;
$result = mysql_query($sql);
echo "<br />表:[".$tablename."]<br />";
//表的字段个数
$filedcount = mysql_num_fields($result);
//记录条数
$recordcount = mysql_num_rows($result);
echo "sql[".$sql."] 记录条数:".$recordcount."<br />";
if($filedcount > 0 )
{
echo "<table border='1'>;
<tr>
<th>记录序号</th>";
for($index=0; $index<$filedcount; $index++)
{
//字段名
$filedname = mysql_fetch_field($result);
echo "<th>$filedname->name</th>";
}
echo "</tr>";
$no = 0;
while($row = mysql_fetch_array($result))
{
$no = $no + 1;
echo "<tr>";
echo "<td>" . $no . "</td>";
for($index=0; $index<$filedcount; $index++)
{
echo "<td>" . $row[$index] . "</td>";
}
echo "</tr>";
}
echo "</table>";
}
}
mysql_close($con);
?>
<?php
//xml解析
echo "<br />"."********xml解析********"."<br />";
/*$xmldoc = new domdocument();
$xmldoc->load("note.xml");
$x = $xmldoc->documentelement;
foreach ($x->childnodes as $item)
{
print $item->nodename . " = " . $item->nodevalue . "<br />";
}*/
$xml = simplexml_load_file("note.xml");
echo $xml->getname() . "<br />";
foreach($xml->children() as $child)
{
echo $child->getname() . ": " . $child . "<br />";
}
?>
<?php
//ajax
echo "<br />"."*******ajax*******"."<br />";
?>
<form>
first name:
<input type="text" id="txt1"
//onkeyup="showhint(this.value)"
onkeyup="show()">
</form>
<p>suggestions: <span id="txthint"></span></p>
</body>
</html>本文地址:http://www.phprm.com/huihua/fs4209.html
转载随意,但请附上文章地址:-)