分享知识的快乐,尊重他人创造的知识 注册 | 登陆
浏览模式: 标准 | 列表2007年07月的文章

调用的静态方法 Static class method call

调用的静态方法  Static class method call
 
  call_user_func 的方法调用. 我遇到一个地方不能理解.

   mixed call_user_func ( callback function [, mixed parameter [, mixed ...]] )

   明明第一个参数是 function .可为什么可以接收一个array参数呢

  <?php
class MyClass{
    function s($i)
    {
        echo $i;
    }
}
$c=new MyClass();
call_user_func(array($c,'s'),2);


?>
  去官方找到一些答案了.

» 阅读全文

Tags: call_user_func, callback

[转载]随机提取N条记录的SQL语句

随机提取N条记录的SQL语句

» 阅读全文

Tags: 随机, rnd()

DOMNodelist->item()

 如果使用DOMXPath 获得返回是DOMNodelist.

可以使用foreach(nodes as node) 

获得属性可以 node->getAttribute("code")

获得值可以 node->nodeValue

如何不用foreach 如何获得

» 阅读全文

Tags: domnodelist, nodevalue

多态性和继承的好处

The subject of polymorphism is probably the most important in OOP. Using classes and inheritance makes it easy to describe a real-life situation as opposed to just a collection of functions and data. They also make it much easier to grow projects by reusing code mainly via inheritance. Also, to write robust and extensible code, you usually want to have as few as possible flow-control statements (such as if() statements). Polymorphism answers all these needs and more.

Consider the following code:

 

» 阅读全文

singleton pattern

You are probably asking yourself if this whole static business is really useful.

One example of using it is to assign a unique id to all instances of a class:

class MyUniqueIdClass {
    static $idCounter = 0;

    public $uniqueId;

    function __construct()
    {
        self::$idCounter++;
        $this->uniqueId = self::$idCounter;
    }
}

$obj1 = new MyUniqueIdClass();
print $obj1->uniqueId . "\n";
$obj2 = new MyUniqueIdClass();
print $obj2->uniqueId . "\n";

» 阅读全文

Tags: singleton, 设计模式

PHP中强大的过滤验证函数

ctype_alnum() Check if a value contains only alphanumeric characters.
ctype_alpha() Check if a value contains only alphabetic characters.
ctype_digit() Check if a value contains only numeric characters.
ctype_print() Check if a value contains only printable characters.
ctype_space() Check if a value contains only white space characters.

» 阅读全文

Tags: ctype, 过滤, 验诈

LAMP的意思

LAMP(Llinux,Apache,mysql,php)

» 阅读全文

Tags: lamp

preg和ereg

 刚学php,发现正则一直在使用 ereg. 可就是不支持 \d 好奇怪
在QQ群一问,他们说要使用preg函数才支持全面正则.
下面是在网站的一些文章.
http://cn.php.net/manual/zh/ref.pcre.php
http://blog.csdn.net/TruthTracer/archive/2006/03/14/624061.aspx

» 阅读全文

Records:912