note 126379 added to function.file
| From: | honza dot stech at gmail dot com | Date: | Wed, 01 Sep 2021 14:25:21 +0000 |
| Subject: | note 126379 added to function.file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216847@lists.php.net to get a copy of this message | ||
Keep in mind that file() will NOT trim the new line characters at the end of the lines.
The means, that for example this code will always output "No bad words detected":
<?php
$badWords = file('badwords.txt');
/* badwords.txt file contents:
love
lust
sex
*/
$comment = "I love PHP!";
foreach ($badWords as $badWord) {
if (mb_stripos($comment, $badWord)) {
exit("Don't use naughty words");
}
}
echo "No bad words detected";
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 178.255.168.15)
----
Manual Page -- https://php.net/manual/en/function.file.php
Edit -- https://main.php.net/note/edit/126379
Del: integrated -- https://main.php.net/note/delete/126379/integrated
Del: useless -- https://main.php.net/note/delete/126379/useless
Del: bad code -- https://main.php.net/note/delete/126379/bad+code
Del: spam -- https://main.php.net/note/delete/126379/spam
Del: non-english -- https://main.php.net/note/delete/126379/non-english
Del: in docs -- https://main.php.net/note/delete/126379/in+docs
Del: other reasons-- https://main.php.net/note/delete/126379
Reject -- https://main.php.net/note/reject/126379
Search -- https://main.php.net/manage/user-notes.php