学习php Reflection(二)
(4)映射类(ReflectionClass)
ReflectionClass类允许你反向映射类。
<?
php
interface MySerializable
{
// ...}
class My
Object
{
// ...}
/** A counter class */
class
Counter
extends
MyObject implements MySerializable
{ const
START
=
0
;
private
static
$c
=
Counter
::
START
;
/**Invoke counter
* @access public
* @return int */
public
function
count
() { return
self
::
$c
++; }
}
// Create an instance of the ReflectionClass class
$class
= new
ReflectionClass
(
'Counter'
);
// Print out basic information
printf
(
"===> The %s%s%s %s '%s' [extends %s]\n"
.
" declared in %s\n"
.
" lines %d to %d\n"
.
" having the modifiers %d [%s]\n"
,
$class
->
isInternal
() ?
'internal'
:
'user-defined'
,
$class
->
isAbstract
() ?
' abstract'
:
''
,
$class
->
isFinal
() ?
' final'
:
''
,
$class
->
isInterface
() ?
'interface'
:
'
相关文档:
原文链接:http://www.phpdo.net/index.php/20100411/56.html
在PHP中使用foreach函数可以遍历数组。Foreach仅能用于数组,语法如下:
Foreach(array as $value) statements
Foreach(array as $key=>$value) statement
第一种语法遍历数组时,每次循环时,当前单元的值被赋给$value,数组内部的指针向前 ......
再次之前先说一个网址: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_ ......
看yii框架源码的时候,发现了
ReflectionClass这个方法,才发现原来是php5的新东西,于是稍微研究了下。php的反射api一共有:
class
Reflection
{ }
interface Reflector
{ }
class
ReflectionException
extends
Exception
{ }
class
Re ......