PHP 8.6.0 Beta 3 is available for testing

taint

(PECL taint >=0.1.0)

taintMark strings as tainted

Опис

function taint(string &$string, string &...$strings): bool

Manually marks the given strings as tainted, as if they had arrived from user input. The variables are passed by reference, but the mark itself is stored on the string rather than on the variable: every variable sharing the same string becomes tainted at once.

This is mainly useful for testing, and for simulating user input in CLI scripts where the $_GET, $_POST and $_COOKIE superglobals are not populated.

Параметри

string

A variable holding the string to mark.

strings

Further variables to mark.

Значення, що повертаються

Always returns true. When taint.enable is off, the function does nothing and still returns true.

Приклади

Приклад #1 taint() example

<?php
$name = "world";
taint($name);
var_dump(is_tainted($name));
?>

Поданий вище приклад виведе щось схоже на:

bool(true)

Примітки

Зауваження:

Only non-empty strings are marked; variables holding other types, or empty strings, are silently ignored.

Зауваження:

Interned, persistent and permanent strings (string literals, opcache shared strings) can never carry the mark and are silently skipped.

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top