當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。