close

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"] 变量有可能会被黑客使用!

<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
在uri打
/test_form.php/%22%3E%3Cscript%3Ealert('hacked')%3C/script%3E

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

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 學習程式 的頭像
    學習程式

    程式學習日記,如果我幫助了你請讓我知道

    學習程式 發表在 痞客邦 留言(0) 人氣()