当前位置: 首页>>代码示例>>PHP>>正文


PHP call_if_exists函数代码示例

本文整理汇总了PHP中call_if_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP call_if_exists函数的具体用法?PHP call_if_exists怎么用?PHP call_if_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了call_if_exists函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: before

function before($route = array())
{
    #print_r($route); exit;
    #inspect the $route array, looking at various options that may have been passed in
    if (@$route['options']['authenticate']) {
        authenticate_user() or halt("Access denied");
    }
    if (@$route['options']['validation_function']) {
        call_if_exists($route['options']['validation_function'], params()) or halt("Woops! Params did not pass validation");
    }
}
开发者ID:Energeyser,项目名称:projet_framework,代码行数:11,代码来源:index.php

示例2: test_main_call_if_exists

function test_main_call_if_exists()
{
    assert_empty(call_if_exists("unknown_function"));
    assert_equal(call_if_exists("count", array(1, 2, 3)), 3);
    assert_length_of(call_if_exists("array_merge", array(1, 2, 3), array(4, 5, 6)), 6);
    class TestCallIfExists
    {
        public function test($value = 1)
        {
            return $value * 10;
        }
        public static function testStatic($value = 1)
        {
            return $value * 20;
        }
    }
    $obj = new TestCallIfExists();
    assert_equal(call_if_exists(array($obj, 'test'), 3), 30);
    assert_equal(call_if_exists(array('TestCallIfExists', 'testStatic'), 3), 60);
    assert_equal(call_if_exists('TestCallIfExists::testStatic', 3), 60);
}
开发者ID:htom78,项目名称:limonade,代码行数:21,代码来源:main.php

示例3: error_handler_dispatcher

/**
 * Internal error handler dispatcher
 * Find and call matching error handler and exit
 * If no match found, call default error handler
 *
 * @access private
 * @param int $errno
 * @param string $errstr
 * @param string $errfile
 * @param string $errline
 * @return void
 */
function error_handler_dispatcher($errno, $errstr, $errfile, $errline)
{
    $back_trace = debug_backtrace();
    while ($trace = array_shift($back_trace)) {
        if ($trace['function'] == 'halt') {
            $errfile = $trace['file'];
            $errline = $trace['line'];
            break;
        }
    }
    # Notices and warning won't halt execution
    if (error_wont_halt_app($errno)) {
        error_notice($errno, $errstr, $errfile, $errline);
        return;
    } else {
        # Other errors will stop application
        $handlers = error();
        $is_http_err = http_response_status_is_valid($errno);
        foreach ($handlers as $handler) {
            $e = is_array($handler['errno']) ? $handler['errno'] : array($handler['errno']);
            while ($ee = array_shift($e)) {
                if ($ee == $errno || $ee == E_LIM_PHP || $ee == E_LIM_HTTP && $is_http_err) {
                    echo call_if_exists($handler['function'], $errno, $errstr, $errfile, $errline);
                    exit;
                }
            }
        }
        echo error_default_handler($errno, $errstr, $errfile, $errline);
        stop_and_exit();
    }
}
开发者ID:plus3network,项目名称:PHPHelpers,代码行数:43,代码来源:limonade.php

示例4: send_header

/**
 * Call before_sending_header() if it exists, then send headers
 * 
 * @param string $header
 * @return void
 */
function send_header($header = null, $replace = true, $code = false)
{
    if (!headers_sent()) {
        call_if_exists('before_sending_header', $header);
        header($header, $replace, $code);
    }
}
开发者ID:soitun,项目名称:CRMx,代码行数:13,代码来源:limonade.php

示例5: error_handler_dispatcher

/**
 * Internal error handler dispatcher
 * Find and call matching error handler and exit
 * If no match found, call default error handler
 *
 * @access private
 * @param int $errno 
 * @param string $errstr 
 * @param string $errfile 
 * @param string $errline 
 * @return void
 */
function error_handler_dispatcher($errno, $errstr, $errfile, $errline)
{
    $back_trace = debug_backtrace();
    while ($trace = array_shift($back_trace)) {
        if ($trace['function'] == 'halt') {
            $errfile = $trace['file'];
            $errline = $trace['line'];
            break;
        }
    }
    $handlers = error();
    $is_http_err = http_response_status_is_valid($errno);
    foreach ($handlers as $handler) {
        $e = is_array($handler['errno']) ? $handler['errno'] : array($handler['errno']);
        while ($ee = array_shift($e)) {
            if ($ee == $errno || $ee == E_LIM_PHP || $ee == E_LIM_HTTP && $is_http_err) {
                echo call_if_exists($handler['function'], $errno, $errstr, $errfile, $errline);
                exit;
            }
        }
    }
    echo error_default_handler($errno, $errstr, $errfile, $errline);
    exit;
}
开发者ID:sofadesign,项目名称:library.dev,代码行数:36,代码来源:limonade.php

示例6: test_main_call_if_exists

function test_main_call_if_exists()
{
    assert_empty(call_if_exists("unknown_function"));
    assert_equal(call_if_exists("count", array(1, 2, 3)), 3);
    assert_length_of(call_if_exists("array_merge", array(1, 2, 3), array(4, 5, 6)), 6);
}
开发者ID:sniemela,项目名称:limonade,代码行数:6,代码来源:main.php


注:本文中的call_if_exists函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。