易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP 中判断、循环的几种写法

下面介绍几种PHP中判断、循环的几种写法。
最普通的判断:
<?php
if( $args != NULL )
{
call_func($args);
}
?>
对于单行的执行语句,可以写成:
<?php
if( $args != NULL ) call_func($args);
?>
也可以使用引号的方式。
<?php
if( $args != NULL ):
call_func($args);
endif;
?>
这中写法通常运用于判断中包含许多HTML标签,或 PHP 的断开,如:
<?php
<?php if( $args! =NULL ): ?>
<p>Args exists</p>
<?php else: ?>
<p>Args NOT exists</p>
<?php endif; ?>
?>
同理,While也可以这么写:
<?php
while( $run ):
call_func();
endwhile;
?>
学过Python的朋友会发现,这种写法其实和Python很相似,用缩进替换了大括号。


相关文档:

PHP封装类效率测试

今天刚学完mysqli,去我的IDC运营商那看了一下,发现他们的虚拟主机居然不支持,我又去其他几家看了看,有的支持有的不支持。
我就想自己写个类,让他去判断,能用mysqli就用mysqli,否则就用原始的mysql函数。不过问题马上就来了,自己写类会不会导致执行效率变低了呢?于是我就进行了如下测试。
这是用来计时的类:
/* ......

php/apc 监控文件上传进度

原文地址: http://blog.csdn.net/lmss82/archive/2010/05/10/5574772.aspx
这是一个完整可用的代码,部分代码来自于网络。
PHP:
5.26
JS环境:
jquery.js,jquery_form.js
使用步骤:
开启APC.
下载php_apc.dll,修改php.ini文件增加以下内容:
extension=php_apc.dll
apc.rfc1867 = On
代码:
<?php
//< ......

PHP: How to Get the Current Page URL

Sometimes, you might want to get the current page URL that is shown
in the browser URL window. For example if you want to let your visitors
submit a blog post to Digg you need to get that same exact URL. There
are plenty of other reasons as well. Here is how you can do that.
Add the followin ......

PHP htmlspecialchars() 函数


定义和用法
htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体。
预定义的字符是:
& (和号) 成为 &amp;
" (双引号) 成为 &quot;
' (单引号) 成为 &#039;
< (小于) 成为 &lt;
> (大于) 成为 &gt;
语法
htmlspecialchars(string,quotestyle,character-se ......

PHP 中 global 变量用法

  PHP中的变量也有访问域。作用域可以使用PHP中global
  在函数内部、对象中和类中定义的局部变量在函数外部是无法被访问到的;同理,在函数外部、对象外和类外定义的变量,如果没有被传入,也是无法被访问到的。
  但是如果一个很多变量要同时被传入很多函数、对象或者类,我们也可以直接将其全局化。这样不仅可以 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号