1.strip_tags
將php or html 的tag消除
<?php
$string_1 = '<p>Welcome to wibibi.</p><a href="#">Test link.</a><!-- 這裡是註解 --> ';
echo strip_tags($string_1).'<br>';
$string_2 = '<p>Welcome to wibibi.</p><a href="#">Test link.</a><!-- 這裡是註解 --> ';
echo strip_tags($string_2,'<p><a>'); 保留a,p的tag
?>
2.<和>的uri逃脫編碼字串
< %3C
> %3E
https://openhome.cc/Gossip/Encoding/URLEncoding.html
3.
$_SERVER["PHP_SELF"] 变量有可能会被黑客使用!
https://www.w3cschool.cn/php/fnrqtfl1.html
黑客可以redirect,讓用戶提交資料到他們的網站
解決辦法:
htmlspecialchars($_SERVER["PHP_SELF"]);?
4.isset的雷點
isset判斷變數是否存在
但如果值是null,會是false
5.正則 preg_match
https://hk.saowen.com/a/ceaf660123e48221dbe1980a0376e63d36d859cbe12a7b7f5097e0a5851973bd
https://www.w3cschool.cn/php/ijxl7fl4.html
ECHO preg_match('/(http|ab)c/',$_GET['a']);
ok的有httpc,abc