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


PHP set_error_handler函数代码示例

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


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

示例1: procesar

 function procesar()
 {
     toba::logger_ws()->debug('Servicio Llamado: ' . $this->info['basica']['item']);
     toba::logger_ws()->set_checkpoint();
     set_error_handler('toba_logger_ws::manejador_errores_recuperables', E_ALL);
     $this->validar_componente();
     //-- Pide los datos para construir el componente, WSF no soporta entregar objetos creados
     $clave = array();
     $clave['proyecto'] = $this->info['objetos'][0]['objeto_proyecto'];
     $clave['componente'] = $this->info['objetos'][0]['objeto'];
     list($tipo, $clase, $datos) = toba_constructor::get_runtime_clase_y_datos($clave, $this->info['objetos'][0]['clase'], false);
     agregar_dir_include_path(toba_dir() . '/php/3ros/wsf');
     $opciones_extension = toba_servicio_web::_get_opciones($this->info['basica']['item'], $clase);
     $wsdl = strpos($_SERVER['REQUEST_URI'], "?wsdl") !== false;
     $sufijo = 'op__';
     $metodos = array();
     $reflexion = new ReflectionClass($clase);
     foreach ($reflexion->getMethods() as $metodo) {
         if (strpos($metodo->name, $sufijo) === 0) {
             $servicio = substr($metodo->name, strlen($sufijo));
             $prefijo = $wsdl ? '' : '_';
             $metodos[$servicio] = $prefijo . $metodo->name;
         }
     }
     $opciones = array();
     $opciones['serviceName'] = $this->info['basica']['item'];
     $opciones['classes'][$clase]['operations'] = $metodos;
     $opciones = array_merge($opciones, $opciones_extension);
     $this->log->debug("Opciones del servidor: " . var_export($opciones, true), 'toba');
     $opciones['classes'][$clase]['args'] = array($datos);
     toba::logger_ws()->set_checkpoint();
     $service = new WSService($opciones);
     $service->reply();
     $this->log->debug("Fin de servicio web", 'toba');
 }
开发者ID:emma5021,项目名称:toba,代码行数:35,代码来源:toba_solicitud_servicio_web.php

示例2: prepareEnvironment

 /**
  * @ignore
  * @param array $options
  */
 public function prepareEnvironment($options = array())
 {
     if (empty($options['skipErrorHandler'])) {
         set_error_handler(array('Ip\\Internal\\ErrorHandler', 'ipErrorHandler'));
     }
     if (empty($options['skipError'])) {
         if (ipConfig()->showErrors()) {
             error_reporting(E_ALL | E_STRICT);
             ini_set('display_errors', '1');
         } else {
             ini_set('display_errors', '0');
         }
     }
     if (empty($options['skipSession'])) {
         if (session_id() == '' && !headers_sent()) {
             //if session hasn't been started yet
             session_name(ipConfig()->get('sessionName'));
             if (!ipConfig()->get('disableHttpOnlySetting')) {
                 ini_set('session.cookie_httponly', 1);
             }
             session_start();
         }
     }
     if (empty($options['skipEncoding'])) {
         mb_internal_encoding(ipConfig()->get('charset'));
     }
     if (empty($options['skipTimezone'])) {
         date_default_timezone_set(ipConfig()->get('timezone'));
         //PHP 5 requires timezone to be set.
     }
 }
开发者ID:x33n,项目名称:ImpressPages,代码行数:35,代码来源:Application.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: __construct

 /**
  * Making the class non-abstract with a protected constructor does a better
  * job of preventing instantiation than just marking the class as abstract.
  *
  * @see start()
  */
 public function __construct(array $configs)
 {
     // Quickly initialize some defaults like usePEAR
     // by adding the $premature flag
     $this->_optionsInit(true);
     $this->setOptions($configs);
     if ($this->opt('logPhpErrors')) {
         set_error_handler(array('self', 'phpErrors'), E_ALL);
     }
     // Check the PHP configuration
     if (!defined('SIGHUP')) {
         trigger_error('PHP is compiled without --enable-pcntl directive', E_USER_ERROR);
     }
     // Check for CLI
     if (php_sapi_name() !== 'cli') {
         trigger_error('You can only create daemon from the command line (CLI-mode)', E_USER_ERROR);
     }
     // Check for POSIX
     if (!function_exists('posix_getpid')) {
         trigger_error('PHP is compiled without --enable-posix directive', E_USER_ERROR);
     }
     // Enable Garbage Collector (PHP >= 5.3)
     if (function_exists('gc_enable')) {
         gc_enable();
     }
     // Initialize & check variables
     if (false === $this->_optionsInit(false)) {
         if (is_object($this->_option) && is_array($this->_option->errors)) {
             foreach ($this->_option->errors as $error) {
                 $this->notice($error);
             }
         }
         trigger_error('Crucial options are not set. Review log:', E_USER_ERROR);
     }
 }
开发者ID:uecode,项目名称:daemon,代码行数:41,代码来源:Daemon.php

示例5: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     set_error_handler(array('Symfony\\Component\\Form\\Test\\DeprecationErrorHandler', 'handleBC'));
     $resolver->setDefaults($this->getDefaultOptions(array()));
     $resolver->addAllowedValues($this->getAllowedOptionValues(array()));
     restore_error_handler();
 }
开发者ID:ronnylt,项目名称:symfony,代码行数:10,代码来源:AbstractType.php

示例6: stringHasController

 function stringHasController(risingsun\ostring $string, controller $controller)
 {
     $pattern = clone $this;
     $previousErrorHandler = set_error_handler(function ($errno, $errstr) use(&$errorMessage) {
         $errorMessage = $errstr;
         return true;
     });
     $match = preg_match($pattern, $string, $matches);
     set_error_handler($previousErrorHandler);
     switch (true) {
         case $match === false:
             throw new \domainException('Pattern \'' . $this . '\' is not a valid PCRE regular expression: ' . $errorMessage);
         case !$match:
             $controller->stringNotMatchPattern($string, $this);
             break;
         default:
             $match = new match($matches[0]);
             if ($pattern->names) {
                 unset($matches[0]);
                 $pattern->matches = array_slice($matches, 0, sizeof(sizeof($pattern->names) <= sizeof($matches) ? $pattern->names : $matches));
                 $pattern->names = array_slice($pattern->names, 0, sizeof($pattern->matches));
             }
             $controller->stringMatchPattern($match, $pattern);
     }
     return $this;
 }
开发者ID:estvoyage,项目名称:risingsun,代码行数:26,代码来源:pcre.php

示例7: start

 /**
  * Starting the error handler
  *
  * @param int $errorLevel
  */
 public static function start($errorLevel = \E_WARNING)
 {
     if (!static::$stack) {
         set_error_handler(array(get_called_class(), 'addError'), $errorLevel);
     }
     static::$stack[] = null;
 }
开发者ID:Flesh192,项目名称:magento,代码行数:12,代码来源:ErrorHandler.php

示例8: run

 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function run()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', "appError"));
     set_exception_handler(array('App', "appException"));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } elseif (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '~app.php');
     } else {
         // 预编译项目
         App::build();
     }
     //[/RUNTIME]
     // 取得模块和操作名称
     define('MODULE_NAME', App::getModule());
     // Module名称
     define('ACTION_NAME', App::getAction());
     // Action操作
     // 记录应用初始化时间
     if (C('SHOW_RUN_TIME')) {
         $GLOBALS['_initTime'] = microtime(TRUE);
     }
     // 执行操作
     R(MODULE_NAME, ACTION_NAME);
     // 保存日志记录
     if (C('LOG_RECORD')) {
         Log::save();
     }
     return;
 }
开发者ID:omusico,项目名称:AndyCMS,代码行数:44,代码来源:App.class.php

示例9: lock

 /**
  * Lock the resource
  *
  * @param  bool        $blocking wait until the lock is released
  * @return bool        Returns true if the lock was acquired, false otherwise
  * @throws IOException If the lock file could not be created or opened
  */
 public function lock($blocking = false)
 {
     if ($this->handle) {
         return true;
     }
     // Silence both userland and native PHP error handlers
     $errorLevel = error_reporting(0);
     set_error_handler('var_dump', 0);
     if (!($this->handle = fopen($this->file, 'r'))) {
         if ($this->handle = fopen($this->file, 'x')) {
             chmod($this->file, 0444);
         } elseif (!($this->handle = fopen($this->file, 'r'))) {
             usleep(100);
             // Give some time for chmod() to complete
             $this->handle = fopen($this->file, 'r');
         }
     }
     restore_error_handler();
     error_reporting($errorLevel);
     if (!$this->handle) {
         $error = error_get_last();
         throw new IOException($error['message'], 0, null, $this->file);
     }
     // On Windows, even if PHP doc says the contrary, LOCK_NB works, see
     // https://bugs.php.net/54129
     if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
         fclose($this->handle);
         $this->handle = null;
         return false;
     }
     return true;
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:39,代码来源:LockHandler.php

示例10: __construct

 public function __construct($options)
 {
     // we need at least PHP7
     if (version_compare(PHP_VERSION, '7.0.0') < 0) {
         throw new Exception("Foundation require PHP 7 or newer.");
     }
     // get all errors
     error_reporting(E_ALL);
     set_error_handler([$this, "errorHandler"]);
     // the application root is foundation directory's upper directory
     $this->rootpath = $options["rootpath"] ?? "../";
     $this->setupApplicationRoot();
     // application timezone
     $this->timezone = $options["timezone"] ?? "UTC";
     $this->setupApplicationTimezone();
     // environment
     $this->env = getenv("ENV") ?? "dev";
     // application namespace
     $this->namespace = $options["namespace"] ?? null;
     if (is_null($this->namespace)) {
         throw new Exception("App Namespace not given.");
     }
     // configure
     $this->config = (object) (require $this->rootpath . "/config/" . $this->env . ".php");
     // register autoloader
     $this->registerAutoloader();
 }
开发者ID:hax4,项目名称:foundation,代码行数:27,代码来源:Foundation.php

示例11: main

 public function main()
 {
     $this->_initDb();
     $cli = new \Console_CommandLine_Result();
     $cli->options = $this->params;
     $cli->args = array('files' => $this->args);
     // Check if we can use colors
     if ($cli->options['color'] === 'auto') {
         $cli->options['color'] = DIRECTORY_SEPARATOR != '\\' && function_exists('posix_isatty') && @posix_isatty(STDOUT);
     } else {
         $cli->options['color'] = filter_var($cli->options['color'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
     }
     if (empty($cli->args['files'])) {
         $cli->args['files'] = array(ROOT . DS . 'spec');
     }
     if (!($cli->options['verbose'] || $cli->options['debug'])) {
         set_error_handler(array($this, 'skipWarning'), E_WARNING | E_NOTICE);
     }
     if ($cli->options['dump']) {
         $module = new DrSlump\Spec\Cli\Modules\Dump($cli);
         $module->run();
     } else {
         $module = new DrSlump\Spec\Cli\Modules\Test($cli);
         $module->run();
     }
 }
开发者ID:nojimage,项目名称:Bdd,代码行数:26,代码来源:SpecShell.php

示例12: search_for_pattern

 function search_for_pattern($search, $limit, $offset, $orderby)
 {
     if (!in_array($orderby, array('asc', 'desc'))) {
         $orderby = 'asc';
     }
     $limit = intval($limit);
     $offset = intval($offset);
     if (strlen($search) > 0) {
         if (!ini_get('safe_mode')) {
             set_time_limit(0);
         }
         // First test that the search and replace strings are valid regex
         if ($this->regex) {
             set_error_handler(array(&$this, 'regex_error'));
             $valid = @preg_match($search, '', $matches);
             restore_error_handler();
             if ($valid === false) {
                 return $this->regex_error;
             }
             return $this->find($search, $limit, $offset, $orderby);
         } else {
             return $this->find('@' . preg_quote($search, '@') . '@', $limit, $offset, $orderby);
         }
     }
     return __("No search pattern", 'search-regex');
 }
开发者ID:kosir,项目名称:thatcamp-org,代码行数:26,代码来源:search.php

示例13: getContentHtml

 public static function getContentHtml($title, $leadOnly)
 {
     $url = 'http://reading-web-research.wmflabs.org/api/slim/';
     if ($leadOnly) {
         $url .= 'lead/';
     }
     $url .= rawurlencode($title);
     set_error_handler(function () {
         throw new Exception('Error at endpoint.');
     }, E_WARNING);
     $resp = file_get_contents($url, false);
     restore_error_handler();
     $json = json_decode($resp);
     $sections = $json->{'sections'};
     if ($leadOnly) {
         $content = $sections[0]->{'content'};
         $continue = Html::element('a', array('id' => 'loot-fold', 'style' => 'clear:both; display: block;', 'href' => '?full=1#continue-from'), 'Continue reading...');
         $content .= $continue;
     } else {
         $content = '';
         foreach ($sections as $key => $section) {
             if ($key > 0) {
                 $content .= '<h2>' . $section->{'title'} . '</h2>';
             }
             $content .= $section->{'content'};
             if ($key === 0) {
                 $content .= '<div id="continue-from"></div>';
             }
         }
     }
     return $content;
 }
开发者ID:jdlrobson,项目名称:LootFrontend,代码行数:32,代码来源:Hooks.php

示例14: onError

 /**
  * Capture all errors and send to provided console
  * 
  * @return mixed Returns a string containing the previously defined error handler (if any)
  */
 public function onError($console, $types = E_ALL)
 {
     $this->errorConsole = $console;
     $this->errorTypes = $types;
     $this->_conditionalErrorConsole = $this->errorConsole->on('Insight: Show all PHP Errors (except:)');
     if ($this->_errorReportingInfo === null) {
         $this->_errorReportingInfo = self::parseErrorReportingBitmask(error_reporting());
         foreach (self::$ERROR_CONSTANTS as $constant => $bit) {
             switch ($constant) {
                 case 'E_ERROR':
                 case 'E_PARSE':
                 case 'E_CORE_ERROR':
                 case 'E_CORE_WARNING':
                 case 'E_COMPILE_ERROR':
                 case 'E_COMPILE_WARNING':
                 case 'E_STRICT':
                 case 'E_ALL':
                     // ignore for now
                     break;
                 default:
                     $this->_conditionalErrorConsole->on($constant);
                     break;
             }
         }
     }
     //NOTE: The following errors will not be caught by this error handler:
     //      E_ERROR, E_PARSE, E_CORE_ERROR,
     //      E_CORE_WARNING, E_COMPILE_ERROR,
     //      E_COMPILE_WARNING, E_STRICT
     return set_error_handler(array($this, '_errorHandler'));
 }
开发者ID:dataReactive,项目名称:firephp,代码行数:36,代码来源:Error.php

示例15: write

 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if (!is_resource($this->stream)) {
         if (!$this->url) {
             throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
         }
         $this->errorMessage = null;
         set_error_handler(array($this, 'customErrorHandler'));
         $this->stream = fopen($this->url, 'a');
         if ($this->filePermission !== null) {
             @chmod($this->url, $this->filePermission);
         }
         restore_error_handler();
         if (!is_resource($this->stream)) {
             $this->stream = null;
             throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: ' . $this->errorMessage, $this->url));
         }
     }
     if ($this->useLocking) {
         // ignoring errors here, there's not much we can do about them
         flock($this->stream, LOCK_EX);
     }
     fwrite($this->stream, (string) $record['formatted']);
     if ($this->useLocking) {
         flock($this->stream, LOCK_UN);
     }
 }
开发者ID:musicsnap,项目名称:Yaf.Global.Library,代码行数:30,代码来源:StreamHandler.php


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