$a = new Auth_HTTP("DB", $AuthOptions);
$a->setRealm('yourrealm'); // realm name
$a->setCancelText('<h2>Error 401</h2>'); // error message if authentication fails
$a->start(); // starting the authentication process
if($a->getAuth()) // checking for autenticated user
{
echo "Hello $a->username welcome to my secret page";
};=======================================================================================<?phprequire_once 'PEAR.php';class myClass {function setValue( $set)
{
$foo = &PEAR::getStaticProperty('myClass', "foo");
$foo = $set;
}function view()
{
print PEAR::getStaticProperty('myClass', "foo");
}}myClass::setValue('value = foo');
myClass::view();
?>==========================================================
$a->setRealm('yourrealm'); // realm name
$a->setCancelText('<h2>Error 401</h2>'); // error message if authentication fails
$a->start(); // starting the authentication process
if($a->getAuth()) // checking for autenticated user
{
echo "Hello $a->username welcome to my secret page";
};=======================================================================================<?phprequire_once 'PEAR.php';class myClass {function setValue( $set)
{
$foo = &PEAR::getStaticProperty('myClass', "foo");
$foo = $set;
}function view()
{
print PEAR::getStaticProperty('myClass', "foo");
}}myClass::setValue('value = foo');
myClass::view();
?>==========================================================
使用::不必用new创建类的实例,直接用类名::方法名就可以使用,这就是类的静态方法或成员。
要用类的实例(即对象)来调用类的方法和属性 就要用"->"" TU如 $a->setRealm() $a->username
用法:对象->方法,对象->属性----------------------------
“::”是用来重新实例化 类的方法和属性
用法:类::类的函数
使用::不必用new创建类的实例,直接用类名::方法名就可以使用,这就是类的静态方法或成员。说的很好
对象是类的实例
----------------
如
类:车 {属性,方法:车的质量 车的速度 车的外观等等}对象:宝马车 (宝马车->车的质量 宝马车->车的速度 宝马车->车的外观 等等)
注意 对象->类的属性方法