php 判断,php 中的判断 总结

php 中的判断 总结

/* 判断常量是否存在*/

if (defined('MYCONSTANT')) {

echo MYCONSTANT;

}

//判断变量是否存在

if (isset($myvar)) {

echo "存在变量$myvar.";

}

//判断函数是否存在

if (function_exists('imap_open')) {

echo "存在函数imag_open\n";

} else {

echo "函数imag_open不存在\n";

}

//判断类是否存在

if (class_exists('MyClass')) {

$myclass = new MyClass();

}

//判断文件是否存在

$filename = '/path/to/foo.txt';

if (file_exists($filename)) {

echo "The file $filename exists";

} else {

echo "The file $filename does not exist";

}

//判断数组中是否存在某成员

$os = array("Mac", "NT", "Irix", "Linux");

if (in_array("Irix", $os)) {

echo "Got Irix";

}

//判断变量类型

is_array()

is_bool()

is_float()

is_integer()

is_null()

is_numeric()

is_object()

is_resource()

is_scalar()

is_string()

?>

相关文档:

【1】页面之间无法传递变量 get,post,session在最新的php版本中自动全局变量是关闭的,所以要从上一页面取得提交过来得变量要使用$_GET['foo'],$_POST['foo'],$_SESSION['foo']来得到。当然也可以修改自动全局变量为开(php.ini改为register_globals = On);考虑到兼容性,还是强迫自己熟悉新的写法比较好。

【2】Wi ......

//单例模式的类Lock

class

Lock

{

//静态属性$instance

&nbsp ......

总结下本人在日常工作中使用php操作word的一些实战。

方法一:利用php com模块

。也即利用word提供的本地api,所有只适用于windows系统上。

$word = new com('word.application') or die('无法打开word');

$word->Visiable = false;

$doc_file = '/path/to/doc';

$word->Open($doc_file);

$text = ' ......

无论哪种语言,字符串操作都是一个重要的基础,往往是简单而重要。正像人说话一样,一般有形体(图形界面),有语言(print 字符串?),显然字符串能解释更多的东西。PHP提供了大量的字符串操作函数,功能强大,使用也比较简单,详细请参看 http://cn2.php.net/manual/zh/ref.strings.php . 以下将简单的讲述它的功能和特� ......

I’ve just updated Aptana Studio from 1.5 to 2.0 only to find out that the spectacular Aptana PHP plugin is not longer supported and its installation has been removed from the Install Additional Features view. However, with some tricks we can still install the old Aptana 1.5.1 in order to use i ......

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值