Hướng dẫn php backslash before function - dấu gạch chéo ngược php trước hàm

(Php 4, Php 5, Php 7, Php 8)

AddSlashes - Chuỗi trích dẫn với dấu gạch chéoQuote string with slashes

Sự mô tả

AddSlashes (Chuỗi $string): Chuỗi(string $string): string

  • Trích dẫn đơn (')
  • Báo giá kép (")
  • Backslash (\)
  • Nul (byte nul)

Một trường hợp sử dụng của AddSlashes () đang thoát khỏi các ký tự đã nói ở trên trong một chuỗi được đánh giá bởi PHP:addslashes() is escaping the aforementioned characters in a string that is to be evaluated by PHP:

$str "O'Reilly?";
eval(
"echo '" addslashes($str) . "';");
?>

AddSlashes () đôi khi được sử dụng không chính xác để cố gắng ngăn ngừa tiêm SQL. Thay vào đó, nên sử dụng các chức năng thoát khỏi cơ sở dữ liệu và/hoặc các câu lệnh được chuẩn bị.addslashes() is sometimes incorrectly used to try to prevent SQL Injection. Instead, database-specific escaping functions and/or prepared statements should be used.

Thông số

string

Chuỗi được thoát ra.

Trả về giá trị

Trả về chuỗi thoát.

Ví dụ

Ví dụ #1 Ví dụ ADDSlashes ()addslashes() example

$str "Is your name O'Reilly?";// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>

Xem thêm

  • dảicslashes () - Chuỗi không truy thích được trích dẫn với addcslashes
  • StripsLashes () - Un -Quotes một chuỗi được trích dẫn
  • addcslashes () - Chuỗi trích dẫn với dấu gạch chéo theo kiểu C
  • HTMLSPECIALCHARS () - Chuyển đổi các ký tự đặc biệt thành các thực thể HTML
  • quoteMeta () - Trích dẫn ký tự meta
  • get_magic_quotes_gpc () - Nhận cài đặt cấu hình hiện tại của Magic_quotes_GPC

Roysimke tại microsoftsfirstmailprovider dot com ¶

12 năm trước

Never use addslashes function to escape values you are going to send to mysql. use mysql_real_escape_string or pg_escape at least if you are not using prepared queries yet.

keep in mind that single quote is not the only special character that can break your sql query. and quotes are the only thing which addslashes care.

svenr tại selfhtml dot org ¶

11 năm trước

'0

'1

'2

'3

Hoskerr tại Nukote Dot Com ¶

19 năm trước

'4

'5

'6

'7

'8

'9

Geekcom ¶

3 năm trước

"1

"2

lai tại n0spam dot pearlmagik dot com ¶

21 năm trước

"4

không có ¶

17 năm trước

"5

David Spector ¶

9 năm trước

"6

"7

Kén chọn, khó tính ¶

16 năm trước

"9

\0

\1

\2

thần thánh76 tại gmail dot com ¶

7 tháng trước

\4

\5

\6

Stuart tại Horuskol Dot Co Dot Uk ¶

13 năm trước

\8

\9

$str "O'Reilly?";
eval(
"echo '" addslashes($str) . "';");
?>
0

$str "O'Reilly?";
eval(
"echo '" addslashes($str) . "';");
?>
1

$str "O'Reilly?";
eval(
"echo '" addslashes($str) . "';");
?>
0

Nate từ Ruggf Family.com

15 năm trước

$str "O'Reilly?";
eval(
"echo '" addslashes($str) . "';");
?>
4

Adrian C ¶

15 năm trước

$str "O'Reilly?";
eval(
"echo '" addslashes($str) . "';");
?>
5

$str "O'Reilly?";
eval(
"echo '" addslashes($str) . "';");
?>
6

$str "O'Reilly?";
eval(
"echo '" addslashes($str) . "';");
?>
7

$str "O'Reilly?";
eval(
"echo '" addslashes($str) . "';");
?>
8

Adrian C ¶

PHP tại slamb dot org ¶

string0

string1

string2

string3

string4

string5

string6

20 năm trước

13 năm trước

string8

Nate từ Ruggf Family.com

17 năm trước

string9

$str "Is your name O'Reilly?";// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>
0

$str "Is your name O'Reilly?";// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>
1

$str "Is your name O'Reilly?";// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>
2

$str "Is your name O'Reilly?";// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>
3

David Spector ¶

9 năm trước

$str "Is your name O'Reilly?";// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>
5

Kén chọn, khó tính ¶

16 năm trước

$str "Is your name O'Reilly?";// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>
6

$str "Is your name O'Reilly?";// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>
7

$str "Is your name O'Reilly?";// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>
8

$str "Is your name O'Reilly?";// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>
9

thần thánh76 tại gmail dot com ¶

7 tháng trước

Never use addslashes function to escape values you are going to send to mysql. use mysql_real_escape_string or pg_escape at least if you are not using prepared queries yet.0

'1

Never use addslashes function to escape values you are going to send to mysql. use mysql_real_escape_string or pg_escape at least if you are not using prepared queries yet.2

Never use addslashes function to escape values you are going to send to mysql. use mysql_real_escape_string or pg_escape at least if you are not using prepared queries yet.3