博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
构造sql的方法
阅读量:4673 次
发布时间:2019-06-09

本文共 882 字,大约阅读时间需要 2 分钟。

PHP sprintf() 函数

参数 format 是转换的格式,以百分比符号 ("%") 开始到转换字符结束。下面的可能的 format 值:    %% - 返回百分比符号    %b - 二进制数    %c - 依照 ASCII 值的字符    %d - 带符号十进制数    %e - 可续计数法(比如 1.5e+3)    %u - 无符号十进制数    %f - 浮点数(local settings aware)    %F - 浮点数(not local settings aware)    %o - 八进制数    %s - 字符串    %x - 十六进制数(小写字母)    %X - 十六进制数(大写字母)

例子 1

例子:$location = 45;$num = 'HuSystem\'s Mountain';$format = "The %s contains %d monkeys";echo printf($format, $num, $location);

例子 2

//对下面的sql语句进行格式化$sql = "select username,user_img,user_pwd from tst_user where user_id = 3";//那么首先列出格式化的变量//比如说从上一个页面得到一个$id = 3;//对这个变量进行格式化$sql = sprintf("select username,user_img,user_pwd from tst_user where user_id = %d", $id);echo $sql; //输出的sql : select username,user_img,user_pwd from tst_user where user_id = 3

sprint('格式化的sql',格式化参数1,格式化参数2,...);

对sql语句的安全处理

 

转载于:https://www.cnblogs.com/Zell-Dinch/articles/3930839.html

你可能感兴趣的文章
企业级docker私有仓库的配置与使用
查看>>
ireport5.6+jasperreport6.3开发(四)--以javabean为基准的报表开发(ireport)
查看>>
Spring面试底层原理的那些问题,你是不是真的懂Spring?
查看>>
Java知识导航总图
查看>>
关于Ajax的实现
查看>>
$cast
查看>>
js 把字符串格式化成时间
查看>>
关于老师
查看>>
[Swift]LeetCode212. 单词搜索 II | Word Search II
查看>>
jquery知识点总结二
查看>>
利用map ,找出list里面string类型,长度最小的那个
查看>>
今天真手贱.
查看>>
【转载】如何使用docker部署c/c++程序
查看>>
Android Binder机制(二) ------- 服务的实现
查看>>
[Algorithm] Find first missing positive integer
查看>>
[Angular] @ViewChild and template #refs to get Element Ref
查看>>
[Angular] Show a loading indicator in Angular using *ngIf/else, the as keyword and the async pipe
查看>>
[Angular] Configurable Angular Components - Content Projection and Input Templates
查看>>
[PWA] 17. Cache the photo
查看>>
[RxJS] ReplaySubject with buffer
查看>>