• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP exception函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: display

 /**
  * 加载模板
  * @param null $template
  */
 public function display($template = null, $isPath = false)
 {
     //$template = isset($template)?self::$routeUrl['module']."/".self::$routeUrl['controller']."_".$template.'.html':self::$routeUrl['module']."_".self::$routeUrl['controller'].'.html';
     //m:c:a or index
     //TODO 代码重用性  ↓↓↓↓↓↓↓
     if (is_array(self::$assignData)) {
         foreach (self::$assignData as $key => $value) {
             self::$view->assign($key, $value);
         }
     }
     //TODO 代码重用性  ↑↑↑↑↑↑↑
     //如果直接 :分割 传入路径 不解析模型 应用于common
     if ($isPath) {
         self::$view->display($template);
         exit;
     }
     if (isset($template)) {
         $pos = strpos($template, ":");
         if ($pos) {
             $tArr = explode(":", $template);
             if (count($tArr) == 3) {
                 $template = $tArr[0] . "/" . $tArr[1] . "_" . $tArr[2];
             } else {
                 return exception($template . "格式错误,必须为 M:C:A!");
             }
         } else {
             $template = self::$routeUrl['module'] . "/" . self::$routeUrl['controller'] . "_" . $template;
         }
     } else {
         $template = self::$routeUrl['module'] . "/" . self::$routeUrl['controller'] . "_" . self::$routeUrl['action'];
     }
     self::$view->display($template);
 }
开发者ID:jayxtt999,项目名称:me,代码行数:37,代码来源:View.class.php


示例2: init

 public static function init($date, $form)
 {
     $dateArray = array();
     $safeFilter = new safeFilter();
     foreach ($date as $k => $v) {
         if (isset($form[$k]['datatype'])) {
             $dataType = $form[$k]['datatype'];
             if (array_key_exists($dataType, self::$type)) {
                 //直接匹配验证
                 if (!preg_match(self::$type[$dataType], $date[$k])) {
                     return exception("不合法的数据:['{$date[$k]}'']");
                 }
             } else {
                 if (array_key_exists(preg_replace("/\\d+/is", "?", $dataType), self::$type)) {
                     //正则匹配
                     $key = preg_replace("/\\d+/is", "?", $dataType);
                     //获取数值
                     preg_match("/.+(\\d)+-(\\d+)/", $dataType, $matchAll);
                     //组装正则
                     $preg = sprintf(self::$type[$key], $matchAll[1], $matchAll[2]);
                     if (!preg_match($preg, $date[$k])) {
                         return exception("不合法的数据:['{$date[$k]}'']");
                     }
                 } elseif (preg_match("/^\\/.*\\/\$/", $dataType)) {
                     //直接正则
                     if (!preg_match($dataType, $date[$k])) {
                         return exception("不合法的数据:['{$date[$k]}'']");
                     }
                 }
             }
         }
     }
     return $date;
 }
开发者ID:jayxtt999,项目名称:me,代码行数:34,代码来源:checkForm.class.php


示例3: set

 /**
  * 设置数据
  *
  * @param int|string $id
  * @param string $key
  * @param $name
  */
 protected function set($id, $key = null, $name = null)
 {
     if (is_null($key) && is_null($name)) {
         exception('请添加正确状态表数据');
     }
     $this->data[$id] = array('id' => $id, 'key' => $key, 'name' => $name);
 }
开发者ID:jayxtt999,项目名称:me,代码行数:14,代码来源:statusGateway.class.php


示例4: handleException

 protected function handleException(Throwable $e)
 {
     if (response()->getCode() == 200) {
         response()->code(404);
     }
     $code = $e->getCode() ? $e->getCode() : response()->getCode();
     $message = $e->getMessage();
     if (class_exists(DeriveAssets::class)) {
         Reflect::create(DeriveAssets::class)->register();
     }
     $handled = false;
     $codes = [$code, 'default'];
     foreach ($codes as $file) {
         try {
             $response = view('Pckg\\Framework:error/' . $file, ['message' => $message, 'code' => $code, 'exception' => $e])->autoparse();
             if ($response) {
                 $handled = true;
                 break;
             }
         } catch (Throwable $e) {
             dd(exception($e));
         }
     }
     if ($handled) {
         echo $response;
     } else {
         echo $code . ' : ' . $message;
     }
     exit;
 }
开发者ID:pckg,项目名称:framework,代码行数:30,代码来源:Production.php


示例5: JsonToArray

 public function JsonToArray($json)
 {
     if (isJson($json)) {
         $array = json_decode($json, true);
         return $array;
     } else {
         throw exception("Invalid Json Array");
     }
 }
开发者ID:jhony112,项目名称:Challenge,代码行数:9,代码来源:Converter.php


示例6: __construct

 /**
  * @param array $options
  */
 public function __construct($options = array())
 {
     if (!extension_loaded('memcache')) {
         exception('_nofund_' . ':memcache');
     }
     $options = array_merge(array('host' => C('cache:memcache:host') ?: '127.0.0.1', 'port' => C('cache:memcache:port') ?: 11211, 'timeout' => C('cache:memcache:timeout') ?: false, 'persistent' => false), $options);
     $this->options = $options;
     $this->options['expire'] = isset($options['expire']) ? $options['expire'] : C('cache:expire');
     $this->options['prefix'] = isset($options['prefix']) ? $options['prefix'] : C('cache:prefix');
     $func = $options['persistent'] ? 'pconnect' : 'connect';
     $this->handler = new \Memcache();
     $options['timeout'] === false ? $this->handler->{$func}($options['host'], $options['port']) : $this->handler->{$func}($options['host'], $options['port'], $options['timeout']);
 }
开发者ID:jayxtt999,项目名称:me,代码行数:16,代码来源:cacheMemcache.class.php


示例7: execute

 public function execute(callable $next)
 {
     try {
         /**
          * First argument is always 'console'.
          * Second argument is app name or command.
          * If it's command, we leave things as they are.
          * Id it's app, we unset it.
          */
         $argv = $_SERVER['argv'];
         /**
          * Remove application name.
          */
         if (isset($argv[1]) && !strpos($argv[1], ':')) {
             unset($argv[1]);
         }
         /**
          * Remove platform name.
          */
         if (isset($argv[2]) && !strpos($argv[2], ':') && false === strpos($argv[2], '-')) {
             unset($argv[2]);
         }
         /**
          * Get Symfony Console Application, find available commands and run app.
          */
         $application = context()->get(SymfonyConsole::class);
         try {
             /**
              * Apply global middlewares.
              */
             if ($middlewares = $this->response->getMiddlewares()) {
                 chain($middlewares, 'execute');
             }
             $application->run(new ArgvInput(array_values($argv)));
             /**
              * Apply global afterwares/decorators.
              */
             if ($afterwares = $this->response->getAfterwares()) {
                 chain($afterwares, 'execute', [$this->response]);
             }
         } catch (Throwable $e) {
             die("EXCEPTION: " . exception($e));
         }
         /**
          * This is here just for better readability. =)
          */
         echo "\n";
     } catch (Throwable $e) {
     }
     return $next();
 }
开发者ID:pckg,项目名称:framework,代码行数:51,代码来源:RunCommand.php


示例8: init

 /**
  * 初始化
  * @param $config
  */
 public function init($type = '', $options = array())
 {
     if (empty($type)) {
         $type = C('cache_type');
     }
     $type = strtolower(trim($type));
     $class = 'System\\Library\\Cache\\cache' . ucwords($type);
     if (class_exists($class)) {
         $this->cache = new $class($options);
     } else {
         exception('CACHE_TYPE Error:' . $type);
     }
     return $this->cache;
 }
开发者ID:jayxtt999,项目名称:me,代码行数:18,代码来源:Cache.class.php


示例9: getAvailableRelations

 public function getAvailableRelations()
 {
     return $this->table->relations->each(function (Relation $relation) {
         $entity = $relation->showTable->createEntity();
         $options = $relation->onField && $relation->dynamic_relation_type_id == 1 ? $entity->all()->each(function ($record) use($relation, $entity) {
             try {
                 $eval = eval(' return ' . $relation->value . '; ');
             } catch (Throwable $e) {
                 $eval = exception($e);
             }
             return ['key' => $record->id, 'value' => $eval];
         }, true) : [];
         return ['id' => $relation->id, 'field' => $relation->id, 'table' => $relation->showTable->table, 'fields' => $this->makeFields($relation->showTable->fields), 'type' => $relation->dynamic_relation_type_id, 'options' => ['options' => $options]];
     });
 }
开发者ID:pckg,项目名称:generic,代码行数:15,代码来源:Fields.php


示例10: routeToCm

 /**
  * 控制器实现
  */
 public static function routeToCm()
 {
     //require_once(APP_PATH.'/'.ucfirst(self::$routeUrl['module']).'/Controller/abstractController.php');
     //require_once(APP_PATH.'/'.ucfirst(self::$routeUrl['module']).'/Controller/'.self::$routeUrl['controller'].'Controller.php');
     //Admin\Controller\Index;
     $controller = "\\" . ucfirst(self::$routeUrl['module']) . "\\Controller\\" . self::$routeUrl['controller'] . 'Controller';
     $controller = new $controller();
     $action = self::$routeUrl['action'] . 'Action';
     try {
         $ca = new \ReflectionMethod($controller, $action);
         $ca->invoke(new $controller(), isset($params) ? $params : null);
     } catch (\Exception $e) {
         exception('控制器方法' . $action . '不存在');
     }
 }
开发者ID:jayxtt999,项目名称:me,代码行数:18,代码来源:Route.class.php


示例11: action

 function action()
 {
     // This needs form validation in a bad way.
     $site = owa_coreAPI::entityFactory('base.site');
     if (!$this->getParam('siteId')) {
         throw exception('No siteId passed on request');
     }
     $site->load($site->generateId($this->getParam('siteId')));
     $site->set('name', $this->getParam('name'));
     $site->set('domain', $this->getParam('domain'));
     $site->set('description', $this->getParam('description'));
     $site->save();
     //$data['view_method'] = 'redirect';
     //$data['do'] = 'base.sites';
     $this->setRedirectAction('base.sites');
     $this->set('status_code', 3201);
 }
开发者ID:ashutoshdev,项目名称:Open-Web-Analytics,代码行数:17,代码来源:sitesEdit.php


示例12: __construct

 function __construct($l = NULL)
 {
     $lang = api_config::getInstance()->lang;
     if (!$l) {
         $currentLang = $lang['default'];
     } else {
         if (in_array($l, $lang['languages'])) {
             $currentlang = $l;
         } else {
             // No language what to do?
             throw exception(new Exception("Language {$l} missing"));
         }
     }
     $langFile = PROJECT_DIR . "config/locale/" . $currentLang . ".yml";
     $yaml = file_get_contents($langFile);
     $langYaml = sfYaml::load($yaml);
     $langArray = $langYaml[$currentLang];
     $this->content = $langArray;
 }
开发者ID:jonolsson,项目名称:Saturday,代码行数:19,代码来源:i18n.php


示例13: fetch

 public function fetch($templateFile = '', $content = '', $prefix = '')
 {
     if (empty($content)) {
         $templateFile = $this->parseTemplate($templateFile);
         if (!is_file($templateFile)) {
             exception("模板文件" . $templateFile . "不存在");
         }
     }
     ob_start();
     ob_implicit_flush(0);
     if ('php' == strtolower($this->config['tmpl_engine_type'])) {
         extract($this->tVar, EXTR_OVERWRITE);
         empty($content) ? include $templateFile : eval('?>' . $content);
     } else {
         $params = array('var' => $this->tVar, 'file' => $templateFile, 'content' => $content, 'prefix' => $prefix);
         $this->ParseTemplateBehavior($params);
     }
     $content = ob_get_clean();
     $this->ContentReplaceBehavior($content);
     return $content;
 }
开发者ID:jayxtt999,项目名称:me,代码行数:21,代码来源:MyTemp.class.php


示例14: handle

 /**
  * We
  */
 public function handle()
 {
     $this->app = $this->getApp();
     if (!$this->app) {
         throw new Exception('App name is required in migrator');
     }
     context()->bind(InstallMigrator::class, $this);
     $requestedMigrations = $this->getRequestedMigrations();
     $installedMigrations = (array) $this->getInstalledMigrations();
     $installed = 0;
     $updated = 0;
     foreach ($requestedMigrations as $requestedMigration) {
         /**
          * @T00D00
          * Implement beforeFirstUp(), beforeUp(), afterUp(), afterFirstUp(), isFirstUp()
          */
         try {
             $migration = new $requestedMigration();
             $migration->up();
             if (!in_array($requestedMigration, $installedMigrations)) {
                 $migration->afterFirstUp();
             }
             $this->output($migration->getRepository() . ' : ' . $requestedMigration);
             $this->output();
         } catch (Throwable $e) {
             dd(exception($e));
         }
         if (in_array($requestedMigration, $installedMigrations)) {
             $updated++;
         } else {
             $installedMigrations[] = $requestedMigration;
             $installed++;
         }
     }
     $this->output('Updated: ' . $updated);
     $this->output('Installed: ' . $installed);
     $this->output('Total: ' . count($installedMigrations));
     $this->putInstalledMigrations($installedMigrations);
 }
开发者ID:pckg,项目名称:migrator,代码行数:42,代码来源:InstallMigrator.php


示例15: internal

 public function internal($url = null)
 {
     try {
         if (!$url) {
             $url = $_SERVER['REQUEST_URI'];
         }
         message('Internal redirect to ' . $url);
         /**
          * Set GET method.
          */
         $_SERVER['REQUEST_METHOD'] = 'GET';
         $_SERVER['REQUEST_URI'] = $url;
         $_POST = [];
         /**
          * Replace prefix in url because environment was already set.
          */
         $url = env()->replaceUrlPrefix($url);
         /**
          * Set request url.
          */
         request()->setUrl($url);
         /**
          * Make request internal so we increase counter.
          */
         request()->setInternal();
         /**
          * Find match.
          */
         request()->init();
         /**
          * Run actions.
          */
         request()->run();
         /**
          * Output.
          */
         response()->run();
         exit;
     } catch (Throwable $e) {
         if (prod()) {
             die(exception($e));
             die("Unknown internal error");
         }
         die(exception($e));
     }
     exit;
 }
开发者ID:pckg,项目名称:framework,代码行数:47,代码来源:Response.php


示例16: delete

 /**
  * 删除记录
  * * @param $table
  * @param array $where
  * @return int
  */
 public function delete($table, array $where)
 {
     if (is_array($where)) {
         $whereData = "";
         $whereVal = array();
         foreach ($where as $key => $val) {
             $whereVal[$key] = $val;
             $wz = strpos($key, "?");
             $parame = $wz ? substr($key, $wz + 1) : "=";
             $k = substr($key, 0, $wz);
             $whereData .= " and " . "`" . $key . "`" . $parame . "(:{$key})";
         }
         $this->sql = "DELETE FROM " . $this->prefix . $table . " WHERE 1=1 " . $whereData;
         try {
             $stmt = $this->pdo->prepare($this->sql);
             $stmt->execute($whereVal);
             return $stmt->rowCount();
         } catch (\Exception $ex) {
             exception($ex->getMessage());
         }
     } else {
         exception("ERROR:delete必须传入参数");
     }
 }
开发者ID:jayxtt999,项目名称:me,代码行数:30,代码来源:PdoMysql.class.php


示例17: registerBuildPackage

 /**
  * Registers a new package of files to be built by 
  * the 'build' CLI command.
  *
  * $package array	the package array takes the form of 
  *
  * 		'name'			=> 'mypackage'
  *		'output_dir'	=> '/path/to/output'
  *		'files'			=> array('foo' => array('path' => '/path/to/file/file.js', 
  *                                              'compression' => 'minify'))	
  */
 protected function registerBuildPackage($package)
 {
     if (!isset($package['name'])) {
         throw exception('Build Package does not have a name.');
     }
     if (!isset($package['output_dir'])) {
         throw exception('Build Package does not have an output directory.');
     } else {
         //check for trailing slash
         $check = substr($package['output_dir'], -1, 1);
         if ($check != '/') {
             $package['output_dir'] = $package['output_dir'] . '/';
         }
     }
     if (!isset($package['files'])) {
         throw exception('Build Package does not any files.');
     }
     // filter the pcakge in case other modules want to change something.
     $eq = owa_coreAPI::getEventDispatch();
     $package = $eq->filter('register_build_package', $package);
     $s = owa_coreAPI::serviceSingleton();
     $s->setMapValue('build_packages', $package['name'], $package);
 }
开发者ID:ashutoshdev,项目名称:Open-Web-Analytics,代码行数:34,代码来源:owa_module.php


示例18: isPriceRange

 /**
  * 0'=>'不限','1'=>'200元以下/天','2'=>'201元-300元/天','3'=>'301元-400元/天','4'=>'401元-500元/天','5'=>'501元-600元/天','6'=>'600元以上/天'
  * 判断每天的价格是否在价格区间中
  * @param $priceRangeType 价格区别的类型编号
  * @param int $basePrice  每天价格
  * @return bool  如果在返回true ,否则返回false
  */
 public static function isPriceRange($priceRangeType, $basePrice = 0)
 {
     $status = false;
     if (!empty($priceRangeType)) {
         $unitPriceRange_array = exception('_', $priceRangeType);
         $unitPriceRange_start = $unitPriceRange_array[0];
         $unitPriceRange_end = $unitPriceRange_array[1];
         if (!is_numeric($unitPriceRange_start) || !is_numeric($unitPriceRange_end)) {
             $return_json = json_encode(array('status' => false, 'error_msg' => '0x190005_unitPriceRange格式不正确'));
             exit($return_json);
         }
     }
     return $status;
 }
开发者ID:lovecheng,项目名称:brs-demo2,代码行数:21,代码来源:RcManager.php


示例19: catch

require_once BASE_PATH . "vendor/autoload.php";
/**
 * Create context instance.
 * This is actually dependency container.
 */
$context = Pckg\Framework\Helper\Context::createInstance();
/**
 * Create development environment.
 * We automatically display errors and load debugbar.
 */
$environment = $context->createEnvironment(Pckg\Framework\Environment\Development::class);
try {
    /**
     * Create application.
     * It should be passed as parameter.
     */
    $application = $context->createConsoleApplication();
    /**
     * Initialize application.
     * This will parse config, set localization 'things', estamblish connection to database,
     * set application autoloaders and providers.
     */
    $application->init();
    /**
     * Run applications.
     * Everything was preset, we need to run command.
     */
    $application->run();
} catch (Throwable $e) {
    dd(exception($e));
}
开发者ID:pckg,项目名称:framework,代码行数:31,代码来源:console.php


示例20: getUsers

 /**
  * Get the list of users.
  *
  * @return Array
  */
 function getUsers()
 {
     if (!Core_Access::isSuperUser()) {
         throw exception('You need to be super user to perform this action');
     }
     $db = Zend_Registry::get('db');
     $select = $db->select()->from('t_users', array('userid', 'coach', 'athlete', 'superuser'))->order('userid DESC');
     $stmt = $db->query($select);
     return $stmt->fetchAll();
 }
开发者ID:ptarcher,项目名称:exercise_mvc,代码行数:15,代码来源:API.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP excerpt函数代码示例发布时间:2022-05-15
下一篇:
PHP example_notifications_optin函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap