学习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'
:
'
相关文档:
遍历目录文件,替换编码部分,删除原文件,再重新转码原文件内容,重新生成新文件。
function explorerdir($sDir){
static $aTempArr=array();
$dp=opendir($sDir);
while ($sFileName = readdir($dp)){
if ($sFileName !='.' && $sFileName !='..'){
......
原文链接: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 ......
Magento遵循一般的方法使用第三方PHP库,即:将php库放到某个目录下,在php.ini或程序头部指定该目录或者父目录指定为include_path,然后程序中使用include_once相对路径包含具体引用的php文件
Magento的lib目录已经默认指定为include_path里了,所以如果有3rd包如Varien放到lib目录下,有一个php文件全名为$magento_h ......