在php网页的开头加入以下
以下为引用的内容:
<?
$time_start = getmicrotime();
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
?>
<?
$time_start = getmicrotime();
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
?>
然后到最后加入以下代码
以下为引用的内容:
<?
$time_end = getmicrotime();
printf ("[页面执行时间: %.2f毫秒]\n\n",($time_end - $time_start)*1000);
?>
$file = fopen($filename, 'r') or die("抱歉,无法打开: $filename");
<?
$time_end = getmicrotime();
printf ("[页面执行时间: %.2f毫秒]\n\n",($time_end - $time_start)*1000);
?>
$file = fopen($filename, 'r') or die("抱歉,无法打开: $filename");
or在这里是这样理解的,因为在php中并不区分数据类型,所以$file既可以是int也可以bool,所以这样的语句不会报错。但其处理过程可能有些朋友不大明白。
其实在大多数的语言中, bool or bool这样的语句中,如果前一个值为真后一个值就不会再判断了。这里也是的,所以如果fopen函数执行正确的话,会返回一个大于0的int值(这其实就是“真”),后面的语句就不会执行了。如果fopen函数执行失败,就会返回false,那么就会判断后面的表达式是否为真了。
结果执行了die()之后,不管返回什么,程序都已经停止执行了,并且显示指定的出错信息,也就达到了调试的目的。
php复选框的问题
以下为引用的内容:
<form name="form1" method="post" action="d.php">
<input type="checkbox" name="checkbox[]" value="111">
111
<input type="checkbox" name="checkbox[]" value="222">
222
<input type="checkbox" name="checkbox[]" value="3333">
333
<input type="checkbox" name="checkbox[]" value="4444">
4444
<input type="checkbox" name="checkbox[]" value="5555">
555
<input type="checkbox" name="checkbox[]" value="6666">
6666
<input type="submit" name="submit" value="提交">
</form>
<form name="form1" method="post" action="d.php">
<input type="checkbox" name="checkbox[]" value="111">
111
<input type="checkbox" name="checkbox[]" value="222">
222
<input type="checkbox" name="checkbox[]" value="3333">
333
<input type="checkbox" name="checkbox[]" value="4444">
4444
<input type="checkbox" name="checkbox[]" value="5555">
555
<input type="checkbox" name="checkbox[]" value="6666">
6666
<input type="submit" name="submit" value="提交">
</form>
d.php
以下为引用的内容:
<?
$fd=$_post['checkbox'];
for ($i = 0; $i < (sizeof($fd)); $i++) {
$newhpt=$newhpt.$fd[$i].",";
}
echo $newhpt."<br>";
?>
<?
$fd=$_post['checkbox'];
for ($i = 0; $i < (sizeof($fd)); $i++) {
$newhpt=$newhpt.$fd[$i].",";
}
echo $newhpt."<br>";
?>
php代码中函数前面的@是什么意思?
@的作用是忽略调用该函数时产生的错误信息。
php中日期相加的问题
以下为引用的内容:
<?
$fd=$_post['checkbox'];
for ($i = 0; $i < (sizeof($fd)); $i++) {
$newhpt=$newhpt.$fd[$i].",";
}
echo $newhpt."<br>";
?>
<?
$fd=$_post['checkbox'];
for ($i = 0; $i < (sizeof($fd)); $i++) {
$newhpt=$newhpt.$fd[$i].",";
}
echo $newhpt."<br>";
?>
0
