當前位置: 首頁>>代碼示例>>PHP>>正文


PHP storage::recover_variables方法代碼示例

本文整理匯總了PHP中storage::recover_variables方法的典型用法代碼示例。如果您正苦於以下問題:PHP storage::recover_variables方法的具體用法?PHP storage::recover_variables怎麽用?PHP storage::recover_variables使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在storage的用法示例。


在下文中一共展示了storage::recover_variables方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: wiki_param

/**
 * gets/sets a wiki_param variable. Also can execute some special actions
 * over a wiki_param (defined by $special param):
 *   'unset' => unsets a wiki_param
 *   'print' or 'print_object': do a print_object of a wiki_param
 *   'isset' => will returns only true or false if a wiki_param is set
 *  'set_info' => load main info into global structure
 *  'all_ws' => (deprecated) returns all variables in a single object
 * 
 * @param String $name: wiki_param name
 * @param mixed $value=null: assign wiki_param value
 * @param Stirng $special=false: some special actions
 * @return mixed: wiki_param value or null if it's not set
 */
function wiki_param($name, $value = null, $special = false)
{
    global $WS;
    if (!isset($WS)) {
        $WS = new storage();
        $WS->recover_variables();
    }
    if ($special == 'set_info') {
        $WS->set_info();
    }
    //this is a deprecated line and will be removed shortly
    if ($special == 'all_ws') {
        return $WS;
    }
    if (!$name) {
        return null;
    }
    if ($value !== null) {
        $WS->{$name} = $value;
    }
    //special actions
    switch ($special) {
        case 'isset':
            return isset($WS->{$name});
            break;
        case 'unset':
            if (isset($WS->{$name})) {
                unset($WS->{$name});
            }
            break;
        case 'print':
        case 'print_object':
            if (isset($WS->{$name})) {
                print_object();
            } else {
                echo '$WS->' . $name . ' is not set!';
            }
            break;
    }
    if (!isset($WS->{$name})) {
        return null;
    }
    return $WS->{$name};
}
開發者ID:hmatulis,項目名稱:RTL-BIDI-Hebrew-Moodle-Plugins,代碼行數:58,代碼來源:misc.lib.php


注:本文中的storage::recover_variables方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。