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


PHP call_user_func函数代码示例

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


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

示例1: session_init

/**
 * Initialize session.
 * @param boolean $keepopen keep session open? The default is
 * 			to close the session after $_SESSION has been populated.
 * @uses $_SESSION
 */
function session_init($keepopen = false)
{
    $settings = new phpVBoxConfigClass();
    // Sessions provided by auth module?
    if (@$settings->auth->capabilities['sessionStart']) {
        call_user_func(array($settings->auth, $settings->auth->capabilities['sessionStart']), $keepopen);
        return;
    }
    // No session support? No login...
    if (@$settings->noAuth || !function_exists('session_start')) {
        global $_SESSION;
        $_SESSION['valid'] = true;
        $_SESSION['authCheckHeartbeat'] = time();
        $_SESSION['admin'] = true;
        return;
    }
    // start session
    session_start();
    // Session is auto-started by PHP?
    if (!ini_get('session.auto_start')) {
        ini_set('session.use_trans_sid', 0);
        ini_set('session.use_only_cookies', 1);
        // Session path
        if (isset($settings->sessionSavePath)) {
            session_save_path($settings->sessionSavePath);
        }
        session_name(isset($settings->session_name) ? $settings->session_name : md5('phpvbx' . $_SERVER['DOCUMENT_ROOT'] . $_SERVER['HTTP_USER_AGENT']));
        session_start();
    }
    if (!$keepopen) {
        session_write_close();
    }
}
开发者ID:rgooler,项目名称:personal-puppet,代码行数:39,代码来源:utils.php

示例2: notify

 public function notify($errno, $errstr, $errfile, $errline, $trace)
 {
     $body = array();
     $body[] = $this->_makeSection("", join("\n", array(@$_SERVER['GATEWAY_INTERFACE'] ? "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" : "", "{$errno}: {$errstr}", "at {$errfile} on line {$errline}")));
     if ($this->_whatToLog & self::LOG_TRACE && $trace) {
         $body[] = $this->_makeSection("TRACE", Debug_ErrorHook_Util::backtraceToString($trace));
     }
     /*if ($this->_whatToLog & self::LOG_SERVER) {
           $body[] = $this->_makeSection("SERVER", Debug_ErrorHook_Util::varExport($_SERVER));
       }*/
     if (!empty($_COOKIE) && $this->_whatToLog & self::LOG_COOKIE) {
         $body[] = $this->_makeSection("COOKIES", Debug_ErrorHook_Util::varExport($_COOKIE));
     }
     if (!empty($_GET) && $this->_whatToLog & self::LOG_GET) {
         $body[] = $this->_makeSection("GET", Debug_ErrorHook_Util::varExport($_GET));
     }
     if (!empty($_POST) && $this->_whatToLog & self::LOG_POST) {
         $body[] = $this->_makeSection("POST", Debug_ErrorHook_Util::varExport($_POST));
     }
     if (!empty($_SESSION) && $this->_whatToLog & self::LOG_SESSION) {
         $body[] = $this->_makeSection("SESSION", Debug_ErrorHook_Util::varExport(@$_SESSION));
     }
     // Append body suffix?
     $suffix = $this->_bodySuffix && is_callable($this->_bodySuffix) ? call_user_func($this->_bodySuffix) : $this->_bodySuffix;
     if ($suffix) {
         $body[] = $this->_makeSection("ADDITIONAL INFO", $suffix);
     }
     // Remain only 1st line for subject.
     $errstr = preg_replace("/\r?\n.*/s", '', $errstr);
     $this->_notifyText("{$errno}: {$errstr} at {$errfile} on line {$errline}", join("\n", $body));
 }
开发者ID:avramishin,项目名称:alishop,代码行数:31,代码来源:TextNotifier.php

示例3: assertErrorsAreTriggered

 /**
  * @param int      $expectedType     Expected triggered error type (pass one of PHP's E_* constants)
  * @param string[] $expectedMessages Expected error messages
  * @param callable $testCode         A callable that is expected to trigger the error messages
  */
 public static function assertErrorsAreTriggered($expectedType, $expectedMessages, $testCode)
 {
     if (!is_callable($testCode)) {
         throw new \InvalidArgumentException(sprintf('The code to be tested must be a valid callable ("%s" given).', gettype($testCode)));
     }
     $e = null;
     $triggeredMessages = array();
     try {
         $prevHandler = set_error_handler(function ($type, $message, $file, $line, $context) use($expectedType, &$triggeredMessages, &$prevHandler) {
             if ($expectedType !== $type) {
                 return null !== $prevHandler && call_user_func($prevHandler, $type, $message, $file, $line, $context);
             }
             $triggeredMessages[] = $message;
         });
         call_user_func($testCode);
     } catch (\Exception $e) {
     } catch (\Throwable $e) {
     }
     restore_error_handler();
     if (null !== $e) {
         throw $e;
     }
     \PHPUnit_Framework_Assert::assertCount(count($expectedMessages), $triggeredMessages);
     foreach ($triggeredMessages as $i => $message) {
         \PHPUnit_Framework_Assert::assertContains($expectedMessages[$i], $message);
     }
 }
开发者ID:unexge,项目名称:symfony,代码行数:32,代码来源:ErrorAssert.php

示例4: createRow

 protected function createRow($items, $aData = array(), $level = 1)
 {
     if ($items->count()) {
         foreach ($items as $itm) {
             $getter = 'get' . $this->getValueField();
             $aResultTmp = array('Value' => call_user_func(array($itm, $getter)), 'Name' => $this->getTextFormat());
             $aRs = array();
             if (preg_match_all("/:(.*):/iU", $aResultTmp['Name'], $aRs)) {
                 foreach ($aRs[1] as $k => $val) {
                     $value = $itm;
                     if (strpos($val, "-") !== false) {
                         $xVal = explode("-", $val);
                         foreach ($xVal as $_val) {
                             $sGetter = 'get' . $_val;
                             $value = call_user_func(array($value, $sGetter));
                         }
                     } else {
                         $sGetter = 'get' . $val;
                         $value = call_user_func(array($value, $sGetter));
                     }
                     $aResultTmp['Name'] = str_replace($aRs[0][$k], $value, $aResultTmp['Name']);
                 }
             }
             if ($this->getIsTree() && $level > 1) {
                 $aResultTmp['Name'] = str_repeat(" |-- ", $level - 1) . $aResultTmp['Name'];
             }
             $aData[] = $aResultTmp;
             if ($itm->hasChilds()) {
                 $aData = $this->createRow($itm->getChilds(), $aData, $level + 1);
             }
         }
     }
     return $aData;
 }
开发者ID:ruxon,项目名称:module-ruxon,代码行数:34,代码来源:RuxonFormViewListColumn.class.php

示例5: array

 /**
  * モジュールの起動(シングルトン)
  *
  * @param  $name string 読み込むモジュール
  * @param  $type string OPTIONAL モジュールのタイプ(wp_attache_mobile|pear)
  * @param  $args mixed モジュールに渡す引数(PEAR のみ使用)
  */
 function &boot($name = null, $type = 'wp_attache_mobile', $args = null)
 {
     static $i = array();
     if (empty($name)) {
         $class = __CLASS__;
         $name = 'controller';
         $i[$name] = new $class();
     } elseif (!isset($i[$name])) {
         if ($type === 'wp_attache_mobile') {
             if (($path = realpath(dirname(__FILE__) . "/modules/{$name}.php")) === false) {
                 wp_attache_mobile::notice(sprintf(__('wp_attache_mobile: %s module not found.', 'wp_attache_mobile'), ucfirst($name)), 'error');
             } else {
                 include $path;
                 $class = "wp_attache_mobile_{$name}";
                 $i[$name] = new $class();
             }
         } elseif ($type === 'pear') {
             if (($path = realpath(sprintf("%s/%s.php", wp_attache_mobile_controller::pear_path(), str_replace('_', '/', $name)))) === false) {
                 wp_die(sprintf(__('wp_attache_mobile: %s PEAR library not found.', 'wp_attache_mobile'), $name));
                 wp_attache_mobile::notice(sprintf(__('wp_attache_mobile: %s PEAR library not found.', 'wp_attache_mobile'), $name), 'error');
             } else {
                 include $path;
                 if (method_exists($name, 'singleton')) {
                     $i[$name] =& call_user_func(array($name, 'singleton'), $args);
                 } else {
                     $i[$name] = new $name();
                 }
             }
         } else {
             wp_die(sprintf(__('wp_attache_mobile: %s is invalid module type.', 'wp_attache_mobile'), $type));
             wp_attache_mobile::notice(sprintf(__('wp_attache_mobile: %s is invalid module type.', 'wp_attache_mobile'), $type), 'error');
         }
     }
     return $i[$name];
 }
开发者ID:ryo88c,项目名称:WordPress-attache-mobile,代码行数:42,代码来源:wp_attache_mobile.php

示例6: forEachFlow

 /**
  * Apply a user function to each flows.
  *
  * @param  callable A callback function
  * @return \FlowConfigurationInterface
  */
 public function forEachFlow(callable $function)
 {
     foreach ($this->flows as $i => $flow) {
         $this->flows[$i] = call_user_func($function, $flow);
     }
     return $this;
 }
开发者ID:adadgio,项目名称:gear-bundle,代码行数:13,代码来源:FlowConfiguration.php

示例7: wait

 /**
  * Loops until the waitCallback returns true and sleeps in between attempts
  * for a length of time specified by the interval. Also emits a WaitEvent
  * during each loop before sleeping.
  *
  * @throws \RuntimeException if the max attempts is exceeded
  */
 public function wait()
 {
     $attempts = 0;
     // Perform an initial delay if configured
     if ($this->config['delay']) {
         usleep($this->config['delay'] * 1000000);
     }
     // If not yet reached max attempts, keep trying to perform wait callback
     while ($attempts < $this->config['max_attempts']) {
         // Perform the callback; if true, then waiting is finished
         if (call_user_func($this->waitCallback)) {
             return;
         }
         // Emit a wait event so collaborators can do something between waits
         $event = new WaitEvent($this->config, $attempts);
         $this->getEmitter()->emit('wait', $event);
         // Wait the specified interval
         if ($interval = $this->config['interval']) {
             if (is_callable($interval)) {
                 $interval = $interval();
             }
             usleep($interval * 1000000);
         }
         $attempts++;
     }
     throw new \RuntimeException("Waiter failed after {$attempts} attempts");
 }
开发者ID:danielcosta,项目名称:sellercenter-sdk,代码行数:34,代码来源:Waiter.php

示例8: loadLanguage

 public static function loadLanguage($langCode = null)
 {
     if (is_null($langCode)) {
         $langCode = self::detectLanguage();
     }
     // If we are asked to load a non-default language, load the English (Great Britain) base translation first
     if ($langCode != 'en-GB') {
         static::loadLanguage('en-GB');
     }
     // Main file
     $filename = APATH_INSTALLATION . '/' . AApplication::getInstance()->getName() . '/language/' . $langCode . '.ini';
     $strings = AngieHelperIni::parse_ini_file($filename, false);
     self::$strings = array_merge(self::$strings, $strings);
     // Platform override file
     $filename = APATH_INSTALLATION . '/' . AApplication::getInstance()->getName() . '/platform/language/' . $langCode . '.ini';
     if (!@file_exists($filename)) {
         $filename = APATH_INSTALLATION . '/platform/language/' . $langCode . '.ini';
     }
     if (@file_exists($filename)) {
         $strings = AngieHelperIni::parse_ini_file($filename, false);
         self::$strings = array_merge(self::$strings, $strings);
     }
     // Performs callback on loaded strings
     if (!empty(static::$iniProcessCallbacks) && !empty(self::$strings)) {
         foreach (static::$iniProcessCallbacks as $callback) {
             $ret = call_user_func($callback, $filename, self::$strings);
             if ($ret === false) {
                 return;
             } elseif (is_array($ret)) {
                 self::$strings = $ret;
             }
         }
     }
 }
开发者ID:akeeba,项目名称:angie,代码行数:34,代码来源:text.php

示例9: fz_dispatcher

function fz_dispatcher()
{
    $controller = 'App_Controller_' . params('controller');
    $controllerInstance = new $controller();
    $controllerInstance->init();
    return call_user_func(array($controllerInstance, params('action') . 'Action'));
}
开发者ID:JAlexandre,项目名称:FileZ,代码行数:7,代码来源:fz_limonade.php

示例10: getIssues

 /**
  * @return array
  */
 public function getIssues()
 {
     if ($this->callback && !$this->callback_invoked) {
         call_user_func($this->callback);
     }
     return $this->issues;
 }
开发者ID:expobrain,项目名称:phpcf,代码行数:10,代码来源:ExecStat.php

示例11: authenticate

 public function authenticate($app, $callback)
 {
     $isLoginUrl = $this->isLoginUrl($app);
     $isValid = $this->isValid($app);
     if (!$isValid) {
         if (!$isLoginUrl) {
             $this->writeRedirect($app, $app->url->requestUrl);
             $this->redirectToLogin($app);
         }
         if ($app->url->requestMethod === 'POST') {
             $userId = $app->post->{$this->options->loginFormUserId};
             $password = $app->post->{$this->options->loginFormPassword};
             if (is_null($callback)) {
                 $user = $this->userProxy->getUserByLoginId($app, $this, $userId);
             } else {
                 $user = call_user_func($callback, $userId);
             }
             $cryptedPassword = $user ? $user->{$this->options->columnPassword} : false;
             $passwordSalt = $user ? $user->{$this->options->columnPasswordSalt} : '';
             if ($cryptedPassword && $this->isValidPassword($password, $cryptedPassword, $passwordSalt)) {
                 $this->login($app, $user);
                 $this->redirectAfterLogin($app);
             } else {
                 $app->error->{$this->options->errorName} = true;
                 $this->redirectToLogin($app);
             }
         }
     } else {
         if ($isLoginUrl) {
             $this->redirectAfterLogin($app);
         }
     }
 }
开发者ID:no22,项目名称:gongo,代码行数:33,代码来源:Auth.php

示例12: filter

 /**
  * {@inheritdoc}
  */
 public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
 {
     if (!is_callable($this->getOption('callback'))) {
         throw new \RuntimeException(sprintf('Please provide a valid callback option "filter" for field "%s"', $this->getName()));
     }
     $this->active = call_user_func($this->getOption('callback'), $queryBuilder, $alias, $field, $data);
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:10,代码来源:CallbackFilter.php

示例13: getDocument

 /**
  * @param mixed $accessor
  * @param bool  $retrieve
  * @return Document|null
  */
 public function getDocument($accessor = null, $retrieve = false)
 {
     if ($accessor === null) {
         $accessor = static::DEFAULT_ACCESSOR;
     }
     if ($accessor === null) {
         // the value contains the document itself
         $doc = $this->value;
         // if the view didn't emit the actual doc as value but was called with include_docs=true
         if (!$doc || !isset($doc->_id) && !isset($doc['_id'])) {
             $doc = $this->doc;
         }
     } elseif (is_callable($accessor)) {
         // an anonymous function or another kind of callback that will grab the value for us
         $doc = call_user_func($accessor, $this);
     } elseif (is_array($this->value) && isset($this->value[$accessor])) {
         // value is an array
         $doc = $this->value[$accessor];
     } elseif (isset($this->value->{$accessor})) {
         // it's the name of a property
         $doc = $this->value->{$accessor};
     } else {
         // exception
     }
     if ($doc) {
         $retval = new Document($this->getViewResult()->getDatabase());
         $retval->hydrate($doc);
         return $retval;
     } elseif ($retrieve) {
         // the view didn't emit the actual doc as value and the view wasn't called with include_docs=true
         return $this->viewResult->getDatabase()->retrieveDocument($this->id);
     } else {
         return null;
     }
 }
开发者ID:dzuelke,项目名称:phpcouch,代码行数:40,代码来源:ViewResultRow.php

示例14: load

 /**
  * Loads all plugins.
  *
  * @param Application $app
  */
 public function load(Application $app)
 {
     foreach ($this->loadConfigs() as $name => $config) {
         if (isset($this->plugins[$name])) {
             continue;
         }
         if (isset($config['autoload'])) {
             foreach ($config['autoload'] as $namespace => $path) {
                 $app['autoloader']->addPsr4($namespace, $config['path'] . "/{$path}");
             }
         }
         if (isset($config['events'])) {
             foreach ($config['events'] as $event => $listener) {
                 $app->on($event, $listener);
             }
         }
         if (is_string($class = $config['main'])) {
             $plugin = new $class();
             if ($plugin instanceof ApplicationAware) {
                 $plugin->setApplication($app);
             }
             if ($plugin instanceof PluginInterface) {
                 $plugin->load($app, $config);
             }
             $this->plugins[$name] = $plugin;
         } elseif (is_callable($config['main'])) {
             $this->plugins[$name] = call_user_func($config['main'], $app, $config) ?: true;
         }
     }
 }
开发者ID:ejailesb,项目名称:repo_empr,代码行数:35,代码来源:PluginManager.php

示例15: RaiseError

 /**
  *   Raises an error.
  *   @param $errorMsg The error message.
  *   @param $field The component field that raised the error, if available.
  */
 protected function RaiseError($errorMsg, $field = null)
 {
     $this->LastError = $errorMsg;
     if (!empty($this->ErrorCallbackFn)) {
         call_user_func($this->ErrorCallbackFn, $this, get_called_class(), $field, $errorMsg);
     }
 }
开发者ID:smiziara,项目名称:Fastcash-Magento,代码行数:12,代码来源:BaseComponent.php


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