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


PHP EvalElse函數代碼示例

本文整理匯總了PHP中EvalElse函數的典型用法代碼示例。如果您正苦於以下問題:PHP EvalElse函數的具體用法?PHP EvalElse怎麽用?PHP EvalElse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: ckr_if_image_count

function ckr_if_image_count($atts, $thing)
{
    // Extract attributes from tag
    extract(lAtts(array('category' => false, 'min' => false, 'max' => false, 'equal' => false, 'not' => false), $atts));
    // Count the images in specified category if given or globally
    $count = $category ? intval(ckr_image_count(array('category' => $category))) : intval(ckr_image_count());
    // Instead of almost unreadable if-else syntax, we use this clever switch-true/case-if counstruct
    switch (true) {
        case $min && !$max && !$equal && !$not:
            // Is greater than min value
            return parse(EvalElse($thing, $count >= intval($min) ? true : false));
            break;
        case $max && !$min && !$equal && !$not:
            // Is lesser than max value
            return parse(EvalElse($thing, $count <= intval($max) ? true : false));
            break;
        case $equal && !$min && !$max && !$not:
            // Is equal
            return parse(EvalElse($thing, $count == intval($equal) ? true : false));
            break;
        case $not && !$min && !$max && !$equal:
            // Is not equal
            return parse(EvalElse($thing, $count != intval($not) ? true : false));
            break;
        case $min && $max && !$equal && !$not:
            // Between min and max
            return parse(EvalElse($thing, $count >= intval($min) && $count <= intval($max) ? true : false));
            break;
        default:
            // Anything else will output an error message
            return '<!-- ckr_if_image_count: Wrong attribute count or combination. -->';
    }
}
開發者ID:nurtext,項目名稱:textpattern-plugins,代碼行數:33,代碼來源:plugin_source.php

示例2: renderIfYield

 /**
  * Conditional for yield.
  *
  * @param  array  $atts
  * @param  string $thing
  * @return string
  */
 public static function renderIfYield($atts, $thing)
 {
     global $yield;
     extract(lAtts(array('value' => null), $atts));
     $inner = end($yield);
     return parse(EvalElse($thing, $inner !== null && ($value === null || (string) $inner === (string) $value)));
 }
開發者ID:bgarrels,項目名稱:textpattern,代碼行數:14,代碼來源:Partial.php

示例3: oui_if_dailymotion

function oui_if_dailymotion($atts, $thing)
{
    global $thisarticle;
    extract(lAtts(array('custom' => null, 'video' => null), $atts));
    $result = $video ? _oui_dailymotion($video) : _oui_dailymotion($thisarticle[strtolower($custom)]);
    return defined('PREF_PLUGIN') ? parse($thing, $result) : parse(EvalElse($thing, $result));
}
開發者ID:NicolasGraph,項目名稱:oui_dailymotion,代碼行數:7,代碼來源:oui_dailymotion.php

示例4: jmd_if_count

/**
 * Evaluate counting results.
 *
 * @param array $atts
 * @property string $atts['eval'] Valid PHP comparison operator.
 * @property string $atts['table'] MySQL table name.
 * @property string $atts['where'] MySQL WHERE clause.
 */
function jmd_if_count($atts, $thing)
{
    extract(lAtts(array('eval' => '', 'table' => '', 'where' => ''), $atts));
    global $jmd_count_value;
    $jmd_count_value = jmd_count(array('table' => $table, 'where' => $where));
    $condition = eval("return({$jmd_count_value} {$eval});");
    $out = EvalElse($thing, $condition);
    return parse($out);
}
開發者ID:jmdeldin,項目名稱:jmd_count,代碼行數:17,代碼來源:count.php

示例5: renderIfLastFile

 /**
  * Checks if the file is the last in the list.
  *
  * @param  array  $atts
  * @param  string $thing
  * @return string
  */
 public static function renderIfLastFile($atts, $thing)
 {
     global $thisfile;
     assert_file();
     return parse(EvalElse($thing, !empty($thisfile['is_last'])));
 }
開發者ID:ClaireBrione,項目名稱:textpattern,代碼行數:13,代碼來源:File.php

示例6: if_jmd_rate_voted

function if_jmd_rate_voted($atts, $thing)
{
    $condition = $GLOBALS['jmd_rate_instance']->voted;
    $out = EvalElse($thing, $condition);
    return parse($out);
}
開發者ID:jmdeldin,項目名稱:jmd_rate,代碼行數:6,代碼來源:jmd_rate.php

示例7: if_custom_field

function if_custom_field($atts, $thing)
{
    global $thisarticle, $prefs;
    extract(lAtts(array('name' => @$prefs['custom_1_set'], 'val' => NULL), $atts));
    if ($val !== NULL) {
        $cond = @$thisarticle[$name] == $val;
    } else {
        $cond = !empty($thisarticle[$name]);
    }
    return parse(EvalElse($thing, $cond));
}
開發者ID:bgarrels,項目名稱:textpattern,代碼行數:11,代碼來源:taghandlers.php

示例8: if_variable

function if_variable($atts, $thing = NULL)
{
    global $variable;
    extract(lAtts(array('name' => '', 'value' => ''), $atts));
    if (empty($name)) {
        trigger_error(gTxt('variable_name_empty'));
        return;
    }
    if (isset($variable[$name])) {
        if (!isset($atts['value'])) {
            $x = true;
        } else {
            $x = $variable[$name] == $value;
        }
    } else {
        $x = false;
    }
    return parse(EvalElse($thing, $x));
}
開發者ID:bgarrels,項目名稱:textpattern,代碼行數:19,代碼來源:taghandlers.php

示例9: zem_if_alice

function zem_if_alice($atts, $thing)
{
    extract(lAtts(array('name' => 'Bob'), $atts));
    return parse(EvalElse($thing, $name == 'Alice'));
}
開發者ID:bgarrels,項目名稱:textpattern,代碼行數:5,代碼來源:zem_plugin_example.php

示例10: l10n_if_lang

 function l10n_if_lang($atts, $thing)
 {
     /*
     Basic markup tag. Use this to wrap blocks of content you only want to appear
     when the specified language is set or if the direction of the selected language matches
     what you want. (Output different css files for rtl layouts for example).
     */
     global $l10n_language;
     $out = '';
     if (!$l10n_language) {
         return $out;
     }
     extract(lAtts(array('lang' => $l10n_language['short'], 'dir' => '', 'wraptag' => ''), $atts));
     if (!empty($dir) and in_array($dir, array('rtl', 'ltr'))) {
         #	Does the direction of the currently selected site language match that requested?
         #	If so, parse the contained content.
         $cond = $dir == MLPLanguageHandler::get_lang_direction($l10n_language['short']);
         $out = parse(EvalElse($thing, $cond)) . n;
     } else {
         #	If the required language matches the site language, output a suitably marked up block of content.
         $cond = ($lang == $l10n_language['short'] or $lang == $l10n_language['long']);
         $out = parse(EvalElse($thing, $cond));
         if (!empty($wraptag)) {
             $dir = MLPLanguageHandler::get_lang_direction_markup($lang);
             $out = "<{$wraptag} lang=\"{$lang}\"{$dir}/>" . $out . "</{$wraptag}>" . n;
         }
     }
     return $out;
 }
開發者ID:netcarver,項目名稱:mlp_pack,代碼行數:29,代碼來源:l10n.php

示例11: sed_if_comments

function sed_if_comments($atts, $thing)
{
    global $thisarticle, $pretext;
    $count = 0;
    if (!isset($thisarticle)) {
        $id = gAtt($atts, 'id', gps('id'));
        if (!$id && @$pretext['id']) {
            $id = $pretext['id'];
        }
        if (isset($id)) {
            $count = safe_field('comments_count', 'textpattern', "id={$id}");
        }
    } else {
        $count = $thisarticle['comments_count'];
    }
    return parse(EvalElse($thing, $count > 0));
}
開發者ID:netcarver,項目名稱:sed_comment_pack,代碼行數:17,代碼來源:sed_comment_pack.php

示例12: jmd_if_neighbor

/**
 * Checks for neighbors.
 * 
 * @param array $atts
 * @param string $atts['type'] Type of neighbor to check for ('next'||'prev')
 */
function jmd_if_neighbor($atts, $thing)
{
    extract(lAtts(array('type' => ''), $atts));
    $condition = $GLOBALS['jmd_neighbor']->type == $type;
    $out = EvalElse($thing, $condition);
    return parse($out);
}
開發者ID:jmdeldin,項目名稱:jmd_neighbor,代碼行數:13,代碼來源:jmd_neighbor.php

示例13: atb_output_form_if_exists

function atb_output_form_if_exists($atts, $thing)
{
    global $yield;
    extract(lAtts(array('name' => ''), $atts));
    if (atb_form_exists($name)) {
        $yield[] = $thing !== null ? parse(EvalElse($thing, true)) : null;
        $outp = parse_form($name);
        array_pop($yield);
    } else {
        $outp = parse(EvalElse($thing, false));
    }
    return $outp;
}
開發者ID:atbradley,項目名稱:atb_if_form,代碼行數:13,代碼來源:atb_if_form.php

示例14: sed_pcf_if_field_section

function sed_pcf_if_field_section($atts, $thing = '')
{
    #	Tests to see if there is a named section of the named custom field.
    global $thisarticle;
    extract(lAtts(array('custom' => '', 'section' => ''), $atts));
    $cond = false;
    $vars = @$thisarticle[$custom];
    if (!empty($vars) and !empty($section)) {
        $vars = sed_lib_extract_packed_variable_section($section, $vars);
        $cond = is_array($vars);
    }
    return parse(EvalElse($thing, $cond));
}
開發者ID:netcarver,項目名稱:sed_pcf,代碼行數:13,代碼來源:sed_pcf.php

示例15: if_data

function if_data($atts, $thing = NULL)
{
    $atts = lAtts(array('debug' => 0, 'ignore' => 0), $atts);
    $f = '/<txp:(\\S+)\\b(.*)(?:(?<!br )(\\/))?' . chr(62) . '(?(3)|(.+)<\\/txp:\\1>)/sU';
    $iftext = EvalElse($thing, true);
    $thresh = 1 + strlen(preg_replace($f, '', $iftext));
    $parsed = parse($iftext);
    if ($atts['ignore']) {
        $parsed = trim($parsed);
    }
    $parsed_len = strlen($parsed);
    $empty = 'Data';
    if (strlen($parsed) < $thresh) {
        #or !preg_match('/\S/', $parsed)) {
        $parsed = parse(EvalElse($thing, false));
        $empty = 'No Data';
    }
    return $atts['debug'] ? "<!-- {$empty} -- Threshhold: {$thresh} Length: {$parsed_len} -->" . $parsed : $parsed;
}
開發者ID:nope,項目名稱:Tipattern,代碼行數:19,代碼來源:taghandlers.php


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