Home  >  Article  >  php教程  >  ThinkPHP 3.1笔记1

ThinkPHP 3.1笔记1

WBOY
WBOYOriginal
2016-06-06 20:07:45993browse

1、使用tp内置的_post()等方法能对变量起到的很好的过滤效果,因为这个方法中默认添加了htmlspecialchars()等过滤函数。 用法:$name = $this->_post(name); // 获取post变量 在配置中添加默认的过滤方式:DEFAULT_FILTER=>strip_tags,htmlspecialchars 具体

1、使用tp内置的_post()等方法能对变量起到的很好的过滤效果,因为这个方法中默认添加了htmlspecialchars()等过滤函数。
用法:$name = $this->_post(‘name’); // 获取post变量
在配置中添加默认的过滤方式:’DEFAULT_FILTER’=>’strip_tags,htmlspecialchars’
具体可参考官方手册。

2、调试sql的方法:getLastSql
具体实例:
$shop_orders = D(‘Orders’);
$orderresult = $shop_orders->where(“order_cookie = ‘”.$_COOKIE['hr_think_userid'].”‘”)->field(‘order_id’)->select();

echo $shop_orders->getLastSql();

ThinkPHP 3.1笔记1 1、使用tp内置的_post()等方法能对变量起到的很好的过滤效果,因为这个方法中默认添加了htmlspecialchars()等过滤函数。 用法:$name = $this->_post(‘name’); // 获取post变量 在配置中添加默认的过滤方式:’DEFAULT_FILTER’=>’strip_tags,htmlspecialchars’ 具体可参考官方手册。 2、调试sql的方法:getLastSql 具体实例: $shop_orders = D(‘Orders’); $orderresult = $shop_orders->where(“order_cookie = ‘”.$_COOKIE['hr_think_userid'].”‘”)->field(‘order_id’)->select(); echo $shop_orders->getLastSql();ThinkPHP 3.1笔记1
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn