建站教程

建站教程

Products

当前位置:首页 > 建站教程 >

(WordPress函数:esc_sql()(过滤 Sql 语句))

GG网络技术分享 2025-03-18 16:13 2


WordPress函数:esc_sql()(过滤 Sql 语句)

esc_sql() 用来过滤准备添加到 Sql 语句里边的字符串,防止 Sql 注入和 Sql 语句被数据干扰出现异常。

用法

esc_sql( $data );

参数

$data

(字符串)(必须)要过滤的字符串。

默认值:None

返回值

(字符串)返回过滤后的字符串,可以直接添加到 Sql 语句里。

例子

$name = esc_sql( $name );

$status = esc_sql( $status );

$wpdb->get_var( \"SELECT something FROM table WHERE foo = \'$name\' and status = \'$status\'\" );

更多

此函数位于:wp-includes/formatting.php

标签:

提交需求或反馈

Demand feedback