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


PHP io::view方法代码示例

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


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

示例1: extensions

 public function extensions()
 {
     /*
      * Ornithopter.io is very simple to use. Some sample controllers and
      * sample models (like this one) have been setup to help you understand
      * the basics of using the MVC framework and structuring projects.
      *
      * Access the framework by calling... io::method();
      */
     // My first name
     $first = 'Corey';
     // My last name
     $last = 'Olson';
     // My birthday is...
     $dob = 'November 14, 1987';
     // My birthday was a long time ago...
     $birthday = io::helper('time')->context(strtotime($dob));
     /*
      * You can check if a $_GET variable exists by using either
      * route::has('var') or the short syntax io::has('var')
      */
     // Hash a password or skip
     if (io::has('do_bcrypt')) {
         // A long time ago I used the password...
         $password = io::helper('security')->hash('yippie');
     } else {
         // Slows down the script runtime severely
         $password = 'Skipped secure password hashing (CPU intensive)';
     }
     // My home town is Chicago...
     date_default_timezone_set('America/Chicago');
     // The current time here is...
     $now = time();
     // Ornithopter.io has built in session management...
     io::library('session');
     // Load the session library on dynamic pages for users
     $session_id = io::library('session')->id();
     // Did you notice that?
     io::library('session')->set('favorite_food', 'pizza');
     // Chaining is allowed on most libraries and helpers (convenience)
     $session = io::library('session');
     // Making a reference; now I can type even less...
     $session->set('favorite_drink', 'coffee');
     // You can call libraries, helpers, models and controllers by shortnames
     $time = io::h('time');
     // Again I can now use the time helper class by referencing $time
     $christmas = $time->prefix('future')->postfix('future')->context(strtotime('December 25 ' . date('Y')));
     // Actually you can call libraries and helpers like this too... (Works for any library or helper)
     $alt = io::html()->tag('blockquote', 'Alternative call to (any helper or library) via <strong>io::html()->tag();</strong>');
     // Now we can show some information with a view
     $page = io::view('example', array('name' => $first . ' ' . $last, 'bday' => $dob, 'bday_ago' => $birthday, 'pwd' => $password, 'currently' => $now, 'sessid' => $session_id, 'xmas_is' => $christmas, 'alt' => $alt));
     /*
      * Noticed how we passed variables to the view? The array we passed to
      * the view will create the $key => $variables within the view for an
      * easy and effective templating system. Just echo the view to see!
      */
     echo $page;
 }
开发者ID:olscore,项目名称:ornithopter.io,代码行数:58,代码来源:demo.php

示例2: __destruct

 /**
  * Generate the page.
  *
  * @return void
  */
 public function __destruct()
 {
     // Check HTTP Status Code
     http_response_code() == 200 ?: exit;
     // Ensure a theme is selected
     if (isset(self::$data['theme'])) {
         // Prepare the page with content
         $__page = \io::view(self::$data['theme'], array('__title' => self::$data['title'], '__description' => self::$data['description'], '__content' => ob_get_contents()));
     } else {
         // Return a page without a theme
         $__page = ob_get_contents();
     }
     // Cleaning output
     ob_end_clean();
     // Send the page to the browser (Compressed) or normally
     echo self::$data['optimize'] ? preg_replace('~>\\s+<~', '> <', $__page) : $__page;
 }
开发者ID:olscore,项目名称:ornithopter.io,代码行数:22,代码来源:page.php


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