在PHP5中,引进了OOP的概念,在类定义中,你可以向其它OOP语言一样(如JAVA),使用
public
protected
private
static
const
extends
abstract
final
等修饰符
另外它的构造器为
function __construct() {}
释放
function __destruct() {}
引用方式:
parent
self
PHP5中还实现了interface的声明方式
interface ITemplate
{
public function setVariable($name, $var);
public function getHtml($template);
}
class Template implements ITemplate
{
private $vars = array();
public function setVariable($name, $var)
{
$this->vars[$name] = $var;
}
public function getHtml($template)
{
foreach($this->vars as $name => $value) {
$template = str_replace('{'.$name.'}', $value, $template);
}
return $template;
}
}
?>
PHP5中实现Overloading,现在还弄不懂什么意思,应该怎样使用它:
void __set (string name, mixed value)
void __get (mixed name)
mixed __call ( string name, array arguments)
异常处理exception
博客介绍了PHP5中引入的OOP概念,包括类定义时可使用的修饰符,构造器和析构器的写法,引用方式。还提及了interface的声明方式及示例,实现Overloading的方法,虽未明确其含义和使用方式,最后提到了异常处理exception。

1474

被折叠的 条评论
为什么被折叠?



