本文整理匯總了PHP中H::app方法的典型用法代碼示例。如果您正苦於以下問題:PHP H::app方法的具體用法?PHP H::app怎麽用?PHP H::app使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類H
的用法示例。
在下文中一共展示了H::app方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: save
/**
* 保存日誌
* @return bool
*/
public function save()
{
$content_arr = $this->getSaveContent();
if (empty($content_arr)) {
return false;
}
$suffix = '.log';
$path = H::app()->log_path . '/' . date('Y/m/d');
if ($this->makeDir($path)) {
foreach ($content_arr as $file_name => $log_arr) {
$file_arr = glob($path . '/' . $file_name . '*.log');
$num = count($file_arr);
if ($num > 0) {
$file_path = $file_arr[$num - 1];
$file_size = filesize($file_path) / 1024;
if ($file_size >= $this->_max_size) {
$num++;
}
} else {
$num++;
}
$file_path = $path . '/' . $file_name . '_' . $num . $suffix;
//寫入方式打開,將文件指針指向文件末尾。如果文件不存在則嘗試創建
$handle = fopen($file_path, 'a');
if ($handle) {
foreach ($log_arr as $content) {
fwrite($handle, $content);
}
fclose($handle);
}
}
}
$this->_log_arr = array();
return true;
}
示例2: defined
<?php
//項目目錄
defined('H_APP_PATH') or define('H_APP_PATH', dirname(__FILE__));
//入口文件
defined('H_APP_ENTRY_FILE') or define('H_APP_ENTRY_FILE', basename(__FILE__));
//引用H+
include H_APP_PATH . '/H+/H.php';
H::app()->run();
示例3: genurl
/**
* 生成url
* @param string $str 生成字符串
* /test test控製器 默認方法
* /test/show test控製器 show方法
* test 當前控製器 test方法
* test/show test控製器 show方法
* @param array $param 需要生成URL的參數數組
* @return string
*/
public function genurl($str, $param = array())
{
$controller = $this->controller;
$char = substr($str, 0, 1);
if ($char == '/') {
$action = substr($str, 1);
} else {
$arr = explode('/', $str);
if (count($arr) > 1) {
$controller = isset($arr[0]) ? $arr[0] : '';
$action = isset($arr[1]) ? $arr[1] : '';
} else {
$action = isset($arr[0]) ? $arr[0] : '';
}
}
$param_arr = array();
//參數數組
//是否為參數路由類型
if (H::app()->getConfig('is_param_route')) {
$param_route_key = H::app()->getConfig('param_route_key');
$param_route_separator = H::app()->getConfig('param_route_separator');
$url = H::app()->base_url . '/' . H_APP_ENTRY_FILE;
$param_arr[] = $param_route_key . '=' . $controller . $param_route_separator . $action;
} else {
$url = H::app()->base_url . '/' . $controller . '/' . $action;
}
//處理參數
foreach ($param as $key => $val) {
$param_arr[] = $key . '=' . $val;
}
if (!empty($param_arr)) {
$url .= '?' . implode('&', $param_arr);
}
return $url;
}
示例4: replyMsgText
/**
* 回複文本消息
* @param string $msg
*/
public function replyMsgText($msg)
{
$fromUserName = $this->_xml_obj->FromUserName;
$toUserName = $this->_xml_obj->ToUserName;
$textTpl = "<xml>\n <ToUserName><![CDATA[%s]]></ToUserName>\n <FromUserName><![CDATA[%s]]></FromUserName>\n <CreateTime>%s</CreateTime>\n <MsgType><![CDATA[%s]]></MsgType>\n <Content><![CDATA[%s]]></Content>\n <FuncFlag>0</FuncFlag>\n </xml>";
$resultStr = sprintf($textTpl, $fromUserName, $toUserName, time(), 'text', $msg);
echo $resultStr;
H::app()->end();
}
示例5:
<link rel="icon" href="<?php
echo H::app()->public_url;
?>
/images/favicon.ico" sizes="any">
<link href="<?php
echo H::app()->public_url;
?>
/login/css/login.css" type="text/css" rel="stylesheet">
<script> window.base_url = '<?php
echo H::app()->base_url;
?>
'; </script>
</head>
<body>
<?php
echo $H_VIEW_HTML;
?>
<script src="<?php
echo H::app()->public_url;
?>
/js/jquery.min.js"></script>
<script src="<?php
echo H::app()->public_url;
?>
/js/md5.min.js"></script>
<script src="<?php
echo H::app()->public_url;
?>
/login/js/login.js"></script>
</body>
</html>
示例6: getKey
protected static function getKey($key)
{
return md5(H::app()->base_path) . $key;
}
示例7: handleError
/**
* 錯誤處理
* @param int $code 錯誤碼
* @param string $message 錯誤消息
* @param string $file 錯誤文件
* @param int $line 錯誤行
*/
public function handleError($code, $message, $file, $line)
{
if ($this->_h_config['is_log']) {
//$trace = debug_backtrace();//需要時候再用
$log = 'Error Code[' . $code . '] Msg[' . $message . '] ' . $file . ' on line ' . $line;
HLog::model()->add($log, HLog::LEVEL_ERROR);
Controller::renderErr($message, $file, $line);
H::app()->end();
}
}
示例8:
<div id="login_box">
<span id="sys_title"><?php
echo H::app()->getConfig('app_name');
?>
</span>
<div>
<input id="user_account" value="<?php
echo $access_token;
?>
" class="login_input" placeholder="賬號" type="text">
</div>
<div>
<input id="user_pwd" value="" class="login_input" placeholder="密碼" type="password">
</div>
<div id="err_msg"></div>
<a id="btn_login" href="javascript:;">登錄</a>
<div id="copyright">© 2015</div>
</div>