}
}
?>
保存为log.php,把下列代码加到head页内,那么将会保护所有的页面。
<? require("log.php");?>
十四、制作一个自动转向:
<?php
header("Refresh:0; url=http://webjx.com");
?>
必须保存为php文件才可以。
十五。制作用户列表:
<?
$customer[0] = 'webjx';
$customer[1] = 'web';
$customer[2] = 'mutou';
$customer[3] = 'chuxia';
$customer[4] = 'shenhua';
echo "第3个用户是: $customer[2]";
echo "<br /><br />所有的用户:<br /><br />";
$number = 5;
$x = 0;
while ($x < $number) {
$customernumber = $x + 0;
echo "Costumer Name $customernumber is $customer[$x]<br />";
++$x;
}
?>
将会显示:
The third customer is mutou
所有的用户:
Costumer Name 0 is webjx
Costumer Name 1 is web
Costumer Name 2 is mutou
Costumer Name 3 is chuxia
Costumer Name 4 is shenhua
另一种读取数组的方法:
<?
echo "3 of my customer are: $customer[0], " . " $customer[1] and " . " $customer[2]. " . "<br />";
?>
将会显示:
3 of my customer are: webjx, web and mutou.
十六.统计某个目录下文件的数量:
<?
echo("There is ");
$dir = "/path/to/the/folder/in/your/computer ";
$count = 0;
$handle=opendir($dir);
while (($file = readdir($handle))!== false){ if ($file != "." && $file != "..") { $count++; }}
echo $count;
ech
| 对此文章发表了评论 |
