学习php Reflection(一)
看yii框架源码的时候,发现了
ReflectionClass这个方法,才发现原来是php5的新东西,于是稍微研究了下。php的反射api一共有:
class
Reflection
{ }
interface Reflector
{ }
class
ReflectionException
extends
Exception
{ }
class
ReflectionFunction implements Reflector
{ }
class
ReflectionParameter implements Reflector
{ }
class
ReflectionMethod
extends
ReflectionFunction
{ }
class
ReflectionClass implements Reflector
{ }
class
ReflectionObject
extends
ReflectionClass
{ }
class
ReflectionProperty implements Reflector
{ }
class
ReflectionExtension implements Reflector
{ }
Reflection 是最基础的反射类,比如
<?php
Reflection::export
(new
ReflectionFunction
('array_walk'
));
Reflection::export
(new
ReflectionClass
('Exception'
));
?>
将输出:
Function [ function array_walk ]
{
- Parameters [3]
{
Parameter #0 [ &$input ]
Parameter #1 [ $funcname ]
Parameter #2 [ $userdata ]
}
}
CODE:
Class [ <internal> class Exception ] {
- Constants [0] { }
- Static properties [0] { }
- Static methods [0] { }
- Properties [6] {
Property [ <default> protected $message ]
Property [ <default> private $string ]
Property [ <default> protected $code ]
Property [ <default> protected $fil
相关文档:
Warning
: Illegal offset type in
Warning
: Illegal offset type in isset or
empty in
前几天写程序的时候碰到一个这种错误提示
如果你使用这样的表示方法如下:
$arr = array();
class a
{
}
$o = new a;
echo $arr[$o];
就会出现上面的错误提示,因为不能使用实例化的对象来作为数组的索引,或者在使用i ......
原文链接:http://www.phpdo.net/index.php/20100410/55.html
在PHP中更新数组的内容可以直接指定键名并且对该键名赋值。 例如:
<?php
$php = array(“php”,”phpdo”,”phpdo.net”);
$php[2] = “www.phpdo.net”;
print_r($php);
&nbs ......
再次之前先说一个网址:https://www.paypaltech.com/SG2/
这个是生成paypal IPN的网址,这样说吧,是替你生成代码的网址(非常的好)!不懂没关系!先知道一下!
下载教程网址:http://download.csdn.net/source/2225766
http://download.cs ......
[转自]http://hi.baidu.com/xiamishule/blog/item/dea92c09ef9acc9e0b7b8236.html
源代码:
PHP获取IP的方法有许多种,<br />今天向大家总结了六种方法。
<br />PHP获取IP方法一:
<?php
function GetIP() {
if(!empty($_SERVER["HTTP_CLIENT_ ......