note 128957 added to function.strip-tags
| From: | makogon-vs at yandex dot ru | Date: | Sat, 14 Oct 2023 01:08:25 +0000 |
| Subject: | note 128957 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220916@lists.php.net to get a copy of this message | ||
One of the most ridiculous and quite common variations of the use of this function, which is often
encountered among newcomers to the world of programming, is the use of this function when processing
query variables:
<?php
$search = isset($_GET['search']) ? strip_tags($_GET['search']) : '';
?>
I donât know the root cause of where this âfashionâ came from, perhaps from yet
another low-quality book on PHP at the beginning of the century. But the fact remains that this
construction is used even now, in the days of PHP8, not only by beginners, but also by developers of
commercial systems.
Please do not use this function in the manner described above. This doesn't make any practical
sense.
The HTML code removal function has nothing to do with data validation, much less the topic of SQL
injections.
Also, you should not use this function when processing data before writing it to the database. It
sounds strange, but you can never be sure that when using this function in the corporate system you
are designing, you will not lose important incoming data that may (or will eventually become) come
in HTML format.
A good practice for building systems is to sketch out the data in its original form, âas
is,â but you can provide this data in client code according to current business requirements.
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 94.143.47.60)
----
Manual Page -- https://php.net/manual/en/function.strip-tags.php
Edit -- https://main.php.net/note/edit/128957
Del: integrated -- https://main.php.net/note/delete/128957/integrated
Del: useless -- https://main.php.net/note/delete/128957/useless
Del: bad code -- https://main.php.net/note/delete/128957/bad+code
Del: spam -- https://main.php.net/note/delete/128957/spam
Del: non-english -- https://main.php.net/note/delete/128957/non-english
Del: in docs -- https://main.php.net/note/delete/128957/in+docs
Del: other reasons-- https://main.php.net/note/delete/128957
Reject -- https://main.php.net/note/reject/128957
Search -- https://main.php.net/manage/user-notes.php