当前位置: 首页>>代码示例>>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;未经允许,请勿转载。