sam 的个人资料>>> 這也將會過去 <<<照片日志列表 工具 帮助
6月18日

PHP Render Page

<?php
// http://tw.php.net/manual/en/ref.outcontrol.php

//{{{ function Render_Page
 /**
  * Description:
  * render template .
  *
  * Usage:
  * ====================================================================
  * // file: test.php
  * $t = dirname(__FILE__) . '/template/test.htm.php'; //also a php file
  * $r = array("id" => "myId", "name" => 'myName');
  * $str = Render_Page($t, $r);
  * var_dump($str);
  * ====================================================================
  * // file : /template/test.htm.php
  * <input id="rid" name="rid" value="<?php echo($r['name'])?>" />
  * <input id="rname" name="rname" vaule="<?php echo($r['name'])?>"/>
  *
  * ====================================================================
  *
  * @param  string $s file location
  * @param  array $r array to replace
  *
  */

 function Render_Page ($s, $r=array())
 {
  global $set;
if($set['debug']) {
  include($s);
} else {
  if (file_exists($s)) {
   @include($s);
  }
}
 }
//}}}

//{{{ function Render_Page_String
 /**
  * Description:
  * get render template string.
  *
  * Usage:
  * ====================================================================
  * // file: test.php
  * $t = dirname(__FILE__) . '/template/test.htm.php'; //also a php file
  * $r = array("id" => "myId", "name" => 'myName');
  * $str = Render_Page_String($t, $r);
  * var_dump($str);
  * ====================================================================
  * // file : /template/test.htm.php
  * <input id="rid" name="rid" value="<?php echo($r['name'])?>" />
  * <input id="rname" name="rname" vaule="<?php echo($r['name'])?>"/>
  *
  * ====================================================================
  *
  * @param  string $s file location
  * @param  array $r array to replace
  *
  */
 function Render_Page_String ($s, $r=array())
 {
  if(!isset($r['load_as_block'])) {
   $r['load_as_block'] = true;
  }
  ob_start();
  ob_clean();
  Render_Page($s, $r);
  $str = ob_get_contents();
  ob_end_clean();
  return $str;
 }


//}}}
?>

HTTP_RAW_POST_DATA

<?php
/*
** =============================================================================
** http://www.php.net/manual/en/reserved.variables.php#reserved.variables.httprawpostdata
** Raw POST data: $HTTP_RAW_POST_DATA
** $HTTP_RAW_POST_DATA contains the raw POST data. See always_populate_raw_post_data
** =============================================================================
** http://www.php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data
** always_populate_raw_post_data  boolean
**
** Always populate the $HTTP_RAW_POST_DATA containing the raw POST data.
** Otherwise, the variable is populated only with unrecognized MIME type of the data.
** However, the preferred method for accessing the raw POST data is php://input.
** $HTTP_RAW_POST_DATA is not available with enctype="multipart/form-data".
** =============================================================================
** http://www.php.net/manual/en/wrappers.php.php
** php://input allows you to read raw POST data.
** It is a less memory intensive alternative to $HTTP_RAW_POST_DATA and does not need any special php.ini directives.
** php://input is not available with enctype="multipart/form-data".
** =============================================================================
**
**
*/
    /**
     * get raw post data
     */
    function getRawPostData($decode=false)
    {
  
        $rtn = file_get_contents('php://input');
        if ($decode) {
            $rtn = urldecode($rtn);
        }
        return $rtn;
    }
?>