?PHP?,urlencode()
???????????URL????????????,?????????:
- ??
rawurlencode()
??:?urlencode()
??,rawurlencode()
?????????,????URL??????,?????????????URL?
$string = "Hello World!"; $encoded_string = rawurlencode($string); echo $encoded_string; // ??: "Hello World!"
- ????????????:?????????????????,???????????????PHP???????,?
filter_var()
,?????????
$user_input = $_POST['username']; $filtered_input = filter_var($user_input, FILTER_SANITIZE_STRING);
- ???????(Prepared Statements):????????,?????????????????SQL???????PDO?MySQLi?????????
// ??PDO $pdo = new PDO('mysql:host=example.com;dbname=testdb', 'username', 'password'); $stmt = $pdo->prepare('INSERT INTO users (username) VALUES (:username)'); $stmt->bindParam(':username', $username); $username = 'JohnDoe'; $stmt->execute(); // ??MySQLi $mysqli = new mysqli('example.com', 'username', 'password', 'testdb'); $stmt = $mysqli->prepare('INSERT INTO users (username) VALUES (?)'); $stmt->bind_param('s', $username); $username = 'JohnDoe'; $stmt->execute();
-
??HTTP POST??:????HTTP POST?????GET?????????,??POST??????????URL?,?????????????
-
???????(HTTPS):????????SSL/TLS??,????????????????????????????????????
-
?????HTTP?:?????HTTP?,?Content-Security-Policy?X-Content-Type-Options?X-Frame-Options,??????????
??,???????????????????PHP????????,??????URL???????