YII Framework學(xué)習(xí)之request與response用法(基于CHttpRequest響應(yīng))
本文實(shí)例講述了YII Framework學(xué)習(xí)之request與response用法。分享給大家供大家參考,具體如下:
YII中提供了CHttpRequest,封裝了請(qǐng)求常用的方法。具體代碼如下:
class CHttpRequest extends CApplicationComponent { public $enableCookieValidation=false; public $enableCsrfValidation=false; public $csrfTokenName='YII_CSRF_TOKEN'; public $csrfCookie; private $_requestUri; private $_pathInfo; private $_scriptFile; private $_scriptUrl; private $_hostInfo; private $_baseUrl; private $_cookies; private $_preferredLanguage; private $_csrfToken; private $_deleteParams; private $_putParams; public function init() { parent::init(); $this->normalizeRequest(); } protected function normalizeRequest() { // normalize request if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { if(isset($_GET)) $_GET=$this->stripSlashes($_GET); if(isset($_POST)) $_POST=$this->stripSlashes($_POST); if(isset($_REQUEST)) $_REQUEST=$this->stripSlashes($_REQUEST); if(isset($_COOKIE)) $_COOKIE=$this->stripSlashes($_COOKIE); } if($this->enableCsrfValidation) Yii::app()->attachEventHandler('onBeginRequest',array($this,'validateCsrfToken')); } public function stripSlashes(&$data) { return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data); } public function getParam($name,$defaultValue=null) { return isset($_GET[$name]) ? $_GET[$name] : (isset($_POST[$name]) ? $_POST[$name] : $defaultValue); } public function getQuery($name,$defaultValue=null) { return isset($_GET[$name]) ? $_GET[$name] : $defaultValue; } public function getPost($name,$defaultValue=null) { return isset($_POST[$name]) ? $_POST[$name] : $defaultValue; } public function getDelete($name,$defaultValue=null) { if($this->_deleteParams===null) $this->_deleteParams=$this->getIsDeleteRequest() ? $this->getRestParams() : array(); return isset($this->_deleteParams[$name]) ? $this->_deleteParams[$name] : $defaultValue; } public function getPut($name,$defaultValue=null) { if($this->_putParams===null) $this->_putParams=$this->getIsPutRequest() ? $this->getRestParams() : array(); return isset($this->_putParams[$name]) ? $this->_putParams[$name] : $defaultValue; } protected function getRestParams() { $result=array(); if(function_exists('mb_parse_str')) mb_parse_str(file_get_contents('php://input'), $result); else parse_str(file_get_contents('php://input'), $result); return $result; } public function getUrl() { return $this->getRequestUri(); } public function getHostInfo($schema='') { if($this->_hostInfo===null) { if($secure=$this->getIsSecureConnection()) $http='https'; else $http='http'; if(isset($_SERVER['HTTP_HOST'])) $this->_hostInfo=$http.'://'.$_SERVER['HTTP_HOST']; else { $this->_hostInfo=$http.'://'.$_SERVER['SERVER_NAME']; $port=$secure ? $this->getSecurePort() : $this->getPort(); if(($port!==80 && !$secure) || ($port!==443 && $secure)) $this->_hostInfo.=':'.$port; } } if($schema!=='') { $secure=$this->getIsSecureConnection(); if($secure && $schema==='https' || !$secure && $schema==='http') return $this->_hostInfo; $port=$schema==='https' ? $this->getSecurePort() : $this->getPort(); if($port!==80 && $schema==='http' || $port!==443 && $schema==='https') $port=':'.$port; else $port=''; $pos=strpos($this->_hostInfo,':'); return $schema.substr($this->_hostInfo,$pos,strcspn($this->_hostInfo,':',$pos+1)+1).$port; } else return $this->_hostInfo; } public function setHostInfo($value) { $this->_hostInfo=rtrim($value,'/'); } public function getBaseUrl($absolute=false) { if($this->_baseUrl===null) $this->_baseUrl=rtrim(dirname($this->getScriptUrl()),'\\/'); return $absolute ? $this->getHostInfo() . $this->_baseUrl : $this->_baseUrl; } public function setBaseUrl($value) { $this->_baseUrl=$value; } public function getScriptUrl() { if($this->_scriptUrl===null) { $scriptName=basename($_SERVER['SCRIPT_FILENAME']); if(basename($_SERVER['SCRIPT_NAME'])===$scriptName) $this->_scriptUrl=$_SERVER['SCRIPT_NAME']; else if(basename($_SERVER['PHP_SELF'])===$scriptName) $this->_scriptUrl=$_SERVER['PHP_SELF']; else if(isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME'])===$scriptName) $this->_scriptUrl=$_SERVER['ORIG_SCRIPT_NAME']; else if(($pos=strpos($_SERVER['PHP_SELF'],'/'.$scriptName))!==false) $this->_scriptUrl=substr($_SERVER['SCRIPT_NAME'],0,$pos).'/'.$scriptName; else if(isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'],$_SERVER['DOCUMENT_ROOT'])===0) $this->_scriptUrl=str_replace('\\','/',str_replace($_SERVER['DOCUMENT_ROOT'],'',$_SERVER['SCRIPT_FILENAME'])); else throw new CException(Yii::t('yii','CHttpRequest is unable to determine the entry script URL.')); } return $this->_scriptUrl; } public function setScriptUrl($value) { $this->_scriptUrl='/'.trim($value,'/'); } public function getPathInfo() { if($this->_pathInfo===null) { $pathInfo=$this->getRequestUri(); if(($pos=strpos($pathInfo,'?'))!==false) $pathInfo=substr($pathInfo,0,$pos); $pathInfo=urldecode($pathInfo); $scriptUrl=$this->getScriptUrl(); $baseUrl=$this->getBaseUrl(); if(strpos($pathInfo,$scriptUrl)===0) $pathInfo=substr($pathInfo,strlen($scriptUrl)); else if($baseUrl==='' || strpos($pathInfo,$baseUrl)===0) $pathInfo=substr($pathInfo,strlen($baseUrl)); else if(strpos($_SERVER['PHP_SELF'],$scriptUrl)===0) $pathInfo=substr($_SERVER['PHP_SELF'],strlen($scriptUrl)); else throw new CException(Yii::t('yii','CHttpRequest is unable to determine the path info of the request.')); $this->_pathInfo=trim($pathInfo,'/'); } return $this->_pathInfo; } public function getRequestUri() { if($this->_requestUri===null) { if(isset($_SERVER['HTTP_X_REWRITE_URL'])) // IIS $this->_requestUri=$_SERVER['HTTP_X_REWRITE_URL']; else if(isset($_SERVER['REQUEST_URI'])) { $this->_requestUri=$_SERVER['REQUEST_URI']; if(isset($_SERVER['HTTP_HOST'])) { if(strpos($this->_requestUri,$_SERVER['HTTP_HOST'])!==false) $this->_requestUri=preg_replace('/^\w+:\/\/[^\/]+/','',$this->_requestUri); } else $this->_requestUri=preg_replace('/^(http|https):\/\/[^\/]+/i','',$this->_requestUri); } else if(isset($_SERVER['ORIG_PATH_INFO'])) // IIS 5.0 CGI { $this->_requestUri=$_SERVER['ORIG_PATH_INFO']; if(!empty($_SERVER['QUERY_STRING'])) $this->_requestUri.='?'.$_SERVER['QUERY_STRING']; } else throw new CException(Yii::t('yii','CHttpRequest is unable to determine the request URI.')); } return $this->_requestUri; } public function getQueryString() { return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:''; } public function getIsSecureConnection() { return isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'],'on'); } public function getRequestType() { return strtoupper(isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:'GET'); } public function getIsPostRequest() { return isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'POST'); } public function getIsDeleteRequest() { return isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'DELETE'); } public function getIsPutRequest() { return isset($_SERVER['REQUEST_METHOD']) && !strcasecmp($_SERVER['REQUEST_METHOD'],'PUT'); } public function getIsAjaxRequest() { return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest'; } public function getServerName() { return $_SERVER['SERVER_NAME']; } public function getServerPort() { return $_SERVER['SERVER_PORT']; } public function getUrlReferrer() { return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null; } public function getUserAgent() { return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null; } public function getUserHostAddress() { return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'127.0.0.1'; } public function getUserHost() { return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null; } public function getScriptFile() { if($this->_scriptFile!==null) return $this->_scriptFile; else return $this->_scriptFile=realpath($_SERVER['SCRIPT_FILENAME']); } public function getBrowser($userAgent=null) { return get_browser($userAgent,true); } public function getAcceptTypes() { return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null; } private $_port; public function getPort() { if($this->_port===null) $this->_port=!$this->getIsSecureConnection() && isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : 80; return $this->_port; } public function setPort($value) { $this->_port=(int)$value; $this->_hostInfo=null; } private $_securePort; public function getSecurePort() { if($this->_securePort===null) $this->_securePort=$this->getIsSecureConnection() && isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : 443; return $this->_securePort; } public function setSecurePort($value) { $this->_securePort=(int)$value; $this->_hostInfo=null; } public function getCookies() { if($this->_cookies!==null) return $this->_cookies; else return $this->_cookies=new CCookieCollection($this); } public function redirect($url,$terminate=true,$statusCode=302) { if(strpos($url,'/')===0) $url=$this->getHostInfo().$url; header('Location: '.$url, true, $statusCode); if($terminate) Yii::app()->end(); } public function getPreferredLanguage() { if($this->_preferredLanguage===null) { if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && ($n=preg_match_all('/([\w\-_]+)\s*(;\s*q\s*=\s*(\d*\.\d*))?/',$_SERVER['HTTP_ACCEPT_LANGUAGE'],$matches))>0) { $languages=array(); for($i=0;$i<$n;++$i) $languages[$matches[1][$i]]=empty($matches[3][$i]) ? 1.0 : floatval($matches[3][$i]); arsort($languages); foreach($languages as $language=>$pref) return $this->_preferredLanguage=CLocale::getCanonicalID($language); } return $this->_preferredLanguage=false; } return $this->_preferredLanguage; } public function sendFile($fileName,$content,$mimeType=null,$terminate=true) { if($mimeType===null) { if(($mimeType=CFileHelper::getMimeTypeByExtension($fileName))===null) $mimeType='text/plain'; } header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header("Content-type: $mimeType"); if(ini_get("output_handler")=='') header('Content-Length: '.(function_exists('mb_strlen') ? mb_strlen($content,'8bit') : strlen($content))); header("Content-Disposition: attachment; filename=\"$fileName\""); header('Content-Transfer-Encoding: binary'); if($terminate) { // clean up the application first because the file downloading could take long time // which may cause timeout of some resources (such as DB connection) Yii::app()->end(0,false); echo $content; exit(0); } else echo $content; } public function xSendFile($filePath, $options=array()) { if(!is_file($filePath)) return false; if(!isset($options['saveName'])) $options['saveName']=basename($filePath); if(!isset($options['mimeType'])) { if(($options['mimeType']=CFileHelper::getMimeTypeByExtension($filePath))===null) $options['mimeType']='text/plain'; } if(!isset($options['xHeader'])) $options['xHeader']='X-Sendfile'; header('Content-type: '.$options['mimeType']); header('Content-Disposition: attachment; filename="'.$options['saveName'].'"'); header(trim($options['xHeader']).': '.$filePath); if(!isset($options['terminate']) || $options['terminate']) Yii::app()->end(); return true; } public function getCsrfToken() { if($this->_csrfToken===null) { $cookie=$this->getCookies()->itemAt($this->csrfTokenName); if(!$cookie || ($this->_csrfToken=$cookie->value)==null) { $cookie=$this->createCsrfCookie(); $this->_csrfToken=$cookie->value; $this->getCookies()->add($cookie->name,$cookie); } } return $this->_csrfToken; } protected function createCsrfCookie() { $cookie=new CHttpCookie($this->csrfTokenName,sha1(uniqid(mt_rand(),true))); if(is_array($this->csrfCookie)) { foreach($this->csrfCookie as $name=>$value) $cookie->$name=$value; } return $cookie; } public function validateCsrfToken($event) { if($this->getIsPostRequest()) { // only validate POST requests $cookies=$this->getCookies(); if($cookies->contains($this->csrfTokenName) && isset($_POST[$this->csrfTokenName])) { $tokenFromCookie=$cookies->itemAt($this->csrfTokenName)->value; $tokenFromPost=$_POST[$this->csrfTokenName]; $valid=$tokenFromCookie===$tokenFromPost; } else $valid=false; if(!$valid) throw new CHttpException(400,Yii::t('yii','The CSRF token could not be verified.')); } } }
request操作的相關(guān)方法,一目了然。
public function init() { parent::init(); $this->normalizeRequest(); } protected function normalizeRequest() { // normalize request if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { if(isset($_GET)) $_GET=$this->stripSlashes($_GET); if(isset($_POST)) $_POST=$this->stripSlashes($_POST); if(isset($_REQUEST)) $_REQUEST=$this->stripSlashes($_REQUEST); if(isset($_COOKIE)) $_COOKIE=$this->stripSlashes($_COOKIE); } if($this->enableCsrfValidation) Yii::app()->attachEventHandler('onBeginRequest',array($this,'validateCsrfToken')); } public function stripSlashes(&$data) { return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data); }
可以看到y(tǒng)ii對(duì)$_GET\$_POST\$_REQUEST\$_COOKIE進(jìn)行了必要的過濾處理,所以可以放心的使用數(shù)據(jù)。
常用的有如下方法:
獲取get參數(shù)
public function getParam($name,$defaultValue=null)
獲取get參數(shù)
public function getQuery($name,$defaultValue=null)
獲取post數(shù)據(jù)
public function getPost($name,$defaultValue=null)
獲取請(qǐng)求的url
public function getUrl()
獲取主機(jī)信息
public function getHostInfo($schema='')
設(shè)置
public function setHostInfo($value)
獲取根目錄
public function getBaseUrl($absolute=false)
獲取當(dāng)前url
public function getScriptUrl()
獲取請(qǐng)求的url
public function getRequestUri()
獲取querystring
public function getQueryString()
判斷是否是https
public function getIsSecureConnection()
獲取請(qǐng)求類型
public function getRequestType()
是否是post請(qǐng)求
public function getIsPostRequest()
是否是ajax請(qǐng)求
public function getIsAjaxRequest()
獲取服務(wù)器名稱
public function getServerName()
獲取服務(wù)端口
public function getServerPort()
獲取引用路徑
public function getUrlReferrer()
獲取用戶ip地址
public function getUserHostAddress()
獲取用戶主機(jī)名稱
public function getUserHost()
獲取執(zhí)行腳本名稱
public function getScriptFile()
獲取cookie
public function getCookies()
重定向
public function redirect($url,$terminate=true,$statusCode=302)
設(shè)置下載文件頭
public function sendFile($fileName,$content,$mimeType=null,$terminate=true) { if($mimeType===null) { if(($mimeType=CFileHelper::getMimeTypeByExtension($fileName))===null) $mimeType='text/plain'; } header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header("Content-type: $mimeType"); if(ini_get("output_handler")=='') header('Content-Length: '.(function_exists('mb_strlen') ? mb_strlen($content,'8bit') : strlen($content))); header("Content-Disposition: attachment; filename=\"$fileName\""); header('Content-Transfer-Encoding: binary'); if($terminate) { // clean up the application first because the file downloading could take long time // which may cause timeout of some resources (such as DB connection) Yii::app()->end(0,false); echo $content; exit(0); } else echo $content; } public function xSendFile($filePath, $options=array()) { if(!is_file($filePath)) return false; if(!isset($options['saveName'])) $options['saveName']=basename($filePath); if(!isset($options['mimeType'])) { if(($options['mimeType']=CFileHelper::getMimeTypeByExtension($filePath))===null) $options['mimeType']='text/plain'; } if(!isset($options['xHeader'])) $options['xHeader']='X-Sendfile'; header('Content-type: '.$options['mimeType']); header('Content-Disposition: attachment; filename="'.$options['saveName'].'"'); header(trim($options['xHeader']).': '.$filePath); if(!isset($options['terminate']) || $options['terminate']) Yii::app()->end(); return true; }
為了防止csrf,yii提供了相應(yīng)的方法
(
CSRF(Cross-site request forgery),中文名稱:跨站請(qǐng)求偽造,也被稱為:one click attack/session riding,縮寫為:CSRF/XSRF。
《CSRF的攻擊方式詳解 黑客必備知識(shí)》
)
public function getCsrfToken() { if($this->_csrfToken===null) { $cookie=$this->getCookies()->itemAt($this->csrfTokenName); if(!$cookie || ($this->_csrfToken=$cookie->value)==null) { $cookie=$this->createCsrfCookie(); $this->_csrfToken=$cookie->value; $this->getCookies()->add($cookie->name,$cookie); } } return $this->_csrfToken; } protected function createCsrfCookie() { $cookie=new CHttpCookie($this->csrfTokenName,sha1(uniqid(mt_rand(),true))); if(is_array($this->csrfCookie)) { foreach($this->csrfCookie as $name=>$value) $cookie->$name=$value; } return $cookie; } public function validateCsrfToken($event) { if($this->getIsPostRequest()) { // only validate POST requests $cookies=$this->getCookies(); if($cookies->contains($this->csrfTokenName) && isset($_POST[$this->csrfTokenName])) { $tokenFromCookie=$cookies->itemAt($this->csrfTokenName)->value; $tokenFromPost=$_POST[$this->csrfTokenName]; $valid=$tokenFromCookie===$tokenFromPost; } else $valid=false; if(!$valid) throw new CHttpException(400,Yii::t('yii','The CSRF token could not be verified.')); } }
對(duì)于$_GET的使用,不僅僅可以使用$_GET和以上提供的相關(guān)方法,在action中,可以綁定到action的方法參數(shù)。
http://www.yiiframework.com/doc/guide/1.1/zh_cn/basics.controller
這里就一并羅列官方給出的說明。
從版本 1.1.4 開始,Yii 提供了對(duì)自動(dòng)動(dòng)作參數(shù)綁定的支持。 就是說,控制器動(dòng)作可以定義命名的參數(shù),參數(shù)的值將由 Yii 自動(dòng)從 $_GET 填充。
為了詳細(xì)說明此功能,假設(shè)我們需要為 PostController 寫一個(gè) create 動(dòng)作。此動(dòng)作需要兩個(gè)參數(shù):
category: 一個(gè)整數(shù),代表帖子(post)要發(fā)表在的那個(gè)分類的ID。
language: 一個(gè)字符串,代表帖子所使用的語言代碼。
從 $_GET 中提取參數(shù)時(shí),我們可以不再下面這種無聊的代碼了:
class PostController extends CController { public function actionCreate() { if(isset($_GET['category'])) $category=(int)$_GET['category']; else throw new CHttpException(404,'invalid request'); if(isset($_GET['language'])) $language=$_GET['language']; else $language='en'; // ... fun code starts here ... } }
現(xiàn)在使用動(dòng)作參數(shù)功能,我們可以更輕松的完成任務(wù):
class PostController extends CController { public function actionCreate($category, $language='en') { $category=(int)$category; // ... fun code starts here ... } }
注意我們?cè)趧?dòng)作方法 actionCreate 中添加了兩個(gè)參數(shù)。 這些參數(shù)的名字必須和我們想要從 $_GET 中提取的名字一致。 當(dāng)用戶沒有在請(qǐng)求中指定 $language 參數(shù)時(shí),這個(gè)參數(shù)會(huì)使用默認(rèn)值 en 。 由于 $category 沒有默認(rèn)值,如果用戶沒有在 $_GET 中提供 category 參數(shù), 將會(huì)自動(dòng)拋出一個(gè) CHttpException (錯(cuò)誤代碼 400) 異常。 Starting from version 1.1.5, Yii also supports array type detection for action parameters. This is done by PHP type hinting using the syntax like the following:
class PostController extends CController { public function actionCreate(array $categories) { // Yii will make sure $categories be an array } }
That is, we add the keyword array in front of $categories in the method parameter declaration. By doing so, if $_GET['categories'] is a simple string, it will be converted into an array consisting of that string.
Note: If a parameter is declared without the array type hint, it means the parameter must be a scalar (i.e., not an array). In this case, passing in an array parameter via $_GET would cause an HTTP exception.
request的使用你只要保持和以前在php中的使用方式一樣,在yii中是不會(huì)出錯(cuò)的
更多關(guān)于Yii相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結(jié)》、《php優(yōu)秀開發(fā)框架總結(jié)》、《smarty模板入門基礎(chǔ)教程》、《php日期與時(shí)間用法總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對(duì)大家基于Yii框架的PHP程序設(shè)計(jì)有所幫助。
- PHP實(shí)現(xiàn)支持GET,POST,Multipart/form-data的HTTP請(qǐng)求類
- php處理restful請(qǐng)求的路由類分享
- 通過JS和PHP兩種方法判斷用戶請(qǐng)求時(shí)使用的瀏覽器類型
- php自定義類fsocket模擬post或get請(qǐng)求的方法
- 解讀PHP的Yii框架中請(qǐng)求與響應(yīng)的處理流程
- YII2框架中使用yii.js實(shí)現(xiàn)的post請(qǐng)求
- yii2 在控制器中驗(yàn)證請(qǐng)求參數(shù)的使用方法
- Yii框架通過請(qǐng)求組件處理get,post請(qǐng)求的方法分析
- Yii 框架控制器創(chuàng)建使用及控制器響應(yīng)操作示例
- Yii框架響應(yīng)組件用法實(shí)例分析
- Yii2框架RESTful API 格式化響應(yīng),授權(quán)認(rèn)證和速率限制三部分詳解
- PHP封裝請(qǐng)求類實(shí)例分析【基于Yii框架】
相關(guān)文章
php empty 函數(shù)判斷結(jié)果為空但實(shí)際值卻為非空的原因解析
這篇文章主要介紹了php empty 函數(shù)判斷結(jié)果為空但實(shí)際值卻為非空的原因解析,下面是腳本之家小編處理之后的調(diào)試記錄,分享到腳本之家平臺(tái),感興趣的朋友一起看看2018-05-05Laravel基礎(chǔ)-關(guān)于引入公共文件的兩種方式
今天小編就為大家分享一篇Laravel基礎(chǔ)-關(guān)于引入公共文件的兩種方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-10-10laravel-admin 實(shí)現(xiàn)給grid的列添加行數(shù)序號(hào)的方法
今天小編就為大家分享一篇laravel-admin 實(shí)現(xiàn)給grid的列添加行數(shù)序號(hào)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-10-10PHP學(xué)習(xí)記錄之常用的魔術(shù)常量詳解
這篇文章主要介紹了PHP學(xué)習(xí)記錄之常用的魔術(shù)常量,結(jié)合實(shí)例形式總結(jié)分析了PHP魔術(shù)常量的功能、原理及常見操作技巧,需要的朋友可以參考下2019-12-12使用PHP和JavaScript判斷請(qǐng)求是否來自微信內(nèi)瀏覽器
這篇文章主要介紹了使用PHP和JavaScript判斷請(qǐng)求是否來自微信內(nèi)瀏覽器,包括在手機(jī)端的程序上使用微信的分享JS腳本的方法,需要的朋友可以參考下2015-08-08在php中設(shè)置session用memcache來存儲(chǔ)的方法總結(jié)
memcached提供了一個(gè)自定義的session處理器可以被用于存儲(chǔ)用戶session數(shù)據(jù)到memcached服務(wù)端,下面通過本文給大家介紹在php中設(shè)置session用memcache來存儲(chǔ)的方法總結(jié),對(duì)php session memcache相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧2016-01-01