学习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,数组内部的指针向前 ......
遍历目录文件,替换编码部分,删除原文件,再重新转码原文件内容,重新生成新文件。
function explorerdir($sDir){
static $aTempArr=array();
$dp=opendir($sDir);
while ($sFileName = readdir($dp)){
if ($sFileName !='.' && $sFileName !='..'){
......
<html>
<head>
<script type="text/javascript">
<!--
function confirmDelete()
{
return confirm("Are you sure you wish to delete this entry?");
}
//-->
</script>
</head>
<body>
<% $var1 = 2;%> ......
Magento遵循一般的方法使用第三方PHP库,即:将php库放到某个目录下,在php.ini或程序头部指定该目录或者父目录指定为include_path,然后程序中使用include_once相对路径包含具体引用的php文件
Magento的lib目录已经默认指定为include_path里了,所以如果有3rd包如Varien放到lib目录下,有一个php文件全名为$magento_h ......
http://www.111cn.net/phper/19/dd73e6624c92e49e7755d3b43719677d.htm
很多网站在首页上做一些链接,让用户来选择将要访问的各自的语言页面,让中国人选择“中文”,韩国人选择“朝鲜语”,等等。那么能不能做程序来自动帮助选择呢?
答案是肯定的,大家都在用google,你用中文系统打开google的首页 ......