previousPEAR::_PEAR() (Previous) (Next) PEAR::registerShutdownFunc()next

View this page in Last updated: Sun, 21 Jun 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

PEAR::getStaticProperty()

PEAR::getStaticProperty() – スタティックプロパティを扱う (package developer related)

Synopsis

require_once 'PEAR.php';

mixed &PEAR::getStaticProperty ( string $class , string $var )

Description

ほぼ、または完全にスタティックなクラスがあり、 スタティックプロパティが必要な場合、 それを模擬するためにこのメソッドを使用することができます。 例えば、メソッドの中で以下のようにします。

<?php
$myVar 
= &PEAR::getStaticProperty('myVar');
?>
リファレンスを使用する必要があることに注意して下さい。 さもないと、プロパティ値は永続しません!

Parameter

  • string $class - getStaticProperty() のコール元のクラス名

  • string $var 取得する変数

Return value

mixed - 変数へのリファレンス。変数がセットされていない場合、 自動的に NULL に初期化されます。

Example

getStaticProperty() の使用

<?php

require_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();
?>

出力は以下となります。

value = foo
previousPEAR::_PEAR() (Previous) (Next) PEAR::registerShutdownFunc()next

Download Documentation Last updated: Sun, 21 Jun 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.