<?php
$conent=5;
function staic_test(){
static $conent=0;
$conent++;
return $conent;
}
echo $conent." <br/>";
++$conent;
echo staic_test();
echo " <br/>";
echo staic_test();
echo " <br/>";
echo staic_test();
?>
这个程序的执行结果为
5、1、2、3
但当我把程序该成一下
<?php
$conent=5;
function staic_test(){
static $conent=0;
return $conent++;
}
echo $conent." <br/>";
++$conent;
echo staic_test();
echo " <br/>";
echo staic_test();
echo " <br/>";
echo staic_test();
?>
执行结果就会发生变化执行结果为:
5、0、1、2
我想问下在这里我只改变了下
在返回的时候一个是$content++;
在return $content;
与执行返回$content++的区别是什么?$content++的作用是先赋值在在加1
return $content++将返回content加1前的值,如果你要一句完成同样的功能,要用return ++$content.
这个是C中++运算前置和后置的区别而已。
<?php
$conent=5;
function staic_test(){
static $conent=0;
$conent++;
return $conent;
}
echo $conent." <br/>"; //这个是5,我无疑问
++$conent; // $conent=5,$conent+1=6 ??不是吗?
echo staic_test(); //$conent重置为0,再+1,输出1
相关问答:
<?php
if($_SERVER['HTTP_REFERER']!=''){
@header("Content-type:image/jpeg");
echo file_get_contents("xlight.jpg");
}
else{
@header("location:ht ......
<?php
if($_SERVER['HTTP_REFERER']!=''){
@header("Content-type:image/jpeg");
echo file_get_contents("xlight.jpg");
}
else{
@header("location:ht ......
各位大侠
求一段php代码
可以实现以下功能
针对不同的浏览器显示不同的图片
就是有一张图片,只想给ie6用户看到
如果ie7、chrome、firefox用户浏览则显示另外一张图片  ......
这个视频讲的很详细, 对新手非常有用, 基本上一看就懂
由于太大了(50m, 我只能上传20m), 我上传不了, 只好贴出下载地址
下载地址: http://ftel1.3800hk.com/0807/080720djxnzj.rar
好东西,下个看看
......
<!--购买数量-->
<div class='buyinfo'>
<table width='auto'>
<tr>
<td><span>购买数量:</sp ......