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


PHP Load::_VAR方法代码示例

本文整理汇总了PHP中Load::_VAR方法的典型用法代码示例。如果您正苦于以下问题:PHP Load::_VAR方法的具体用法?PHP Load::_VAR怎么用?PHP Load::_VAR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Load的用法示例。


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

示例1: _loadfile

 /**
  * This function is used to load views and files.
  * Variables are prefixed with __ to avoid symbol collision with
  * variables made available to view files
  **/
 private static function _loadfile($name, $vars, $__return, $ispath = false)
 {
     //  we make sure that vars is an array even if it's empty.
     if (!is_array($vars)) {
         $vars = array();
     }
     //  if $name refers to a file located in the views directory
     //  or to an absolute file path.
     if (!$ispath) {
         // Add the views directory path and the default
         // file extension if $name of doesn't contain one
         $__path = pathinfo($name, PATHINFO_EXTENSION) != '' ? VIEW . $name : VIEW . $name . EXT;
     } else {
         $__path = $name;
     }
     if (!file_exists($__path)) {
         Core::error('404MSG', 'LIBTIT', array(__CLASS__, $name));
     }
     // Extract variables to file (if any).
     // Note: We're merging the $vars array with the self::$_VAR array
     // so we can use either of the two methods available for accessing these vars.
     extract(self::$_VAR = array_merge(self::$_VAR, $vars));
     // Unset variables so they don't interfere with files' vars.
     unset($name, $vars, $ispath);
     // Start buffering
     ob_start();
     // Forcing PHP Short Tags
     // Note: I recommend not to use this feature, if your PHP installation
     // doesn't support it natively and you plan to code a complex application.
     // It's wasting processing time just for avoiding to write some chars. don't be lazy!
     if ((bool) @ini_get('short_open_tag') === false && Core::config('force_short_tags') === true) {
         echo eval('?>' . preg_replace("/;*\\s*\\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($__path))) . '<?php ');
     } else {
         require $__path;
     }
     // return the file data if requested
     if ($__return) {
         $b = ob_get_contents();
         ob_end_clean();
         return $b;
     }
     // Flushing the buffer
     // In order to allow views to be nested within other views, we need to flush
     // the content back out whenever we are beyond the first level of Output Buffering
     // So it can be seen and included properly by the first included template and any subsequent ones. Oy!
     if (!Core::obflush()) {
         $c = ob_get_contents();
         ob_end_clean();
         Output::append($c);
     }
 }
开发者ID:hectormenendez,项目名称:h23,代码行数:56,代码来源:load.php


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