validate_file()验证文件是否存在

目录

描述

Used to prevent directory traversal attacks, or to test a filename against a whitelist.

validate_file() 描述

用法

validate_file() 用法

参数

$file

(string) (必填) The file path.

默认值: None

$allowed_files

(array) (可选) An array of allowed files

默认值: null

validate_file() 参数

返回值

(0) 

$file represents a valid relative path. You must treat it as a relative path after validating.

(1) 

$file is invalid and contains either '..' or './'

(2) 

$file is invalid and contains ':' after the first character.

(3) 

$file is invalid and is not in the $allowed_file list.

validate_file() 返回值

示例

validate_file() 示例

注意

Be careful making boolean interpretations of the result, since false (0) indicates the filename has passed validation, whereas true (> 0) indicates failure.

validate_file() 注意

源文件

validate_file() 函数的代码位于 wp-includes/functions.php.

validate_file() 源文件

相关