PHP 8.6.0 Beta 3 is available for testing

is_tainted

(PECL taint >=0.1.0)

is_tainted检查一个字符串是否被污染

说明

function is_tainted(string $string): bool

检查给定的值是否携带污点标记。只有字符串可能被污染, 其他任何类型都返回 false

参数

string

待检查的值。

返回值

如果该值是被污染的字符串,返回 true,否则返回 false。 当 taint.enable 未开启时, 始终返回 false

示例

示例 #1 is_tainted() 示例

<?php
$name = $_GET['name'] ?? 'world';
var_dump(is_tainted($name));
?>

以上示例的输出类似于:

bool(true)

参见

  • taint() - 将字符串标记为已污染
  • untaint() - 清除字符串上的污点标记

添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top