Những ký tự nào nên được thoát khỏi php?

Vì các chương trình PHP thường tương tác với các trang HTML, địa chỉ web (URL) và cơ sở dữ liệu nên có các chức năng giúp bạn làm việc với các loại dữ liệu đó. Các lệnh HTML, địa chỉ trang web và cơ sở dữ liệu đều là các chuỗi, nhưng chúng yêu cầu các ký tự khác nhau được thoát theo các cách khác nhau. Chẳng hạn, một khoảng trắng trong địa chỉ web phải được viết là $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

2, trong khi dấu nhỏ hơn nghĩa đen ($input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

3) trong tài liệu HTML phải được viết là $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

3. PHP có một số chức năng tích hợp để chuyển đổi sang và từ các bảng mã này

Các ký tự đặc biệt trong HTML được đại diện bởi các thực thể như $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

5 và $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

3. Có hai hàm PHP biến các ký tự đặc biệt trong một chuỗi thành các thực thể của chúng. một để xóa các thẻ HTML và một để chỉ trích xuất các thẻ $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

7

Thực thể trích dẫn tất cả các ký tự đặc biệt

Hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

8 thay đổi tất cả các ký tự có tương đương thực thể HTML thành các ký tự tương đương đó (ngoại trừ ký tự khoảng trắng). Điều này bao gồm dấu nhỏ hơn (_______03), dấu lớn hơn ($output = htmlspecialchars(input, [quote_style, [charset]]);0), dấu và ($input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

5) và các ký tự có dấu

Ví dụ

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

0

Phiên bản thoát thực thể ($output = htmlspecialchars(input, [quote_style, [charset]]);2—được xem bằng cách xem nguồn) hiển thị chính xác dưới dạng ü trong trang web được hiển thị. Như bạn có thể thấy, không gian đã không được biến thành $output = htmlspecialchars(input, [quote_style, [charset]]);3

Hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

8 thực sự có tới ba đối số

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

4

Tham số $output = htmlspecialchars(input, [quote_style, [charset]]);5, nếu được cung cấp, xác định bộ ký tự. Mặc định là “ISO-8859-1. ” Tham số $output = htmlspecialchars(input, [quote_style, [charset]]);6 kiểm soát xem dấu ngoặc đơn và dấu ngoặc kép có được chuyển thành dạng thực thể của chúng hay không. $output = htmlspecialchars(input, [quote_style, [charset]]);7 (mặc định) chỉ chuyển đổi dấu ngoặc kép, $output = htmlspecialchars(input, [quote_style, [charset]]);8 chuyển đổi cả hai loại dấu ngoặc kép và $output = htmlspecialchars(input, [quote_style, [charset]]);9 không chuyển đổi. Không có tùy chọn để chỉ chuyển đổi dấu nháy đơn. Ví dụ

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

Thực thể chỉ trích dẫn các ký tự cú pháp HTML

Hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

10 chuyển đổi tập hợp thực thể nhỏ nhất có thể để tạo HTML hợp lệ. Các thực thể sau được chuyển đổi

  • Dấu và ($input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

    End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

    5) được chuyển đổi thành $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

    End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

    5

  • Dấu ngoặc kép (______213) được chuyển đổi thành $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

    End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

    13

  • Dấu nháy đơn ($input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

    End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

    15) được chuyển đổi thành $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

    End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

    15 (nếu bật $output = htmlspecialchars(input, [quote_style, [charset]]);8, như được mô tả cho $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

    End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

    8)

  • Dấu nhỏ hơn ($input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

    End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

    3) được chuyển đổi thành $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

    End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

    3

  • Các dấu hiệu lớn hơn ($output = htmlspecialchars(input, [quote_style, [charset]]);0) được chuyển đổi thành $output = htmlspecialchars(input, [quote_style, [charset]]);0

Nếu bạn có một ứng dụng hiển thị dữ liệu mà người dùng đã nhập vào biểu mẫu, bạn cần chạy dữ liệu đó thông qua $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

10 trước khi hiển thị hoặc lưu dữ liệu đó. Nếu không, và người dùng nhập một chuỗi như $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

54 hoặc $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

55, trình duyệt sẽ nghĩ rằng các ký tự đặc biệt là HTML, dẫn đến một trang bị cắt xén

Giống như $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

8, $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

10 có thể có tối đa ba đối số

________số 8

Các đối số $output = htmlspecialchars(input, [quote_style, [charset]]);6 và $output = htmlspecialchars(input, [quote_style, [charset]]);5 có cùng ý nghĩa như đối với $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

8

Không có chức năng cụ thể để chuyển ngược lại từ các thực thể về văn bản gốc, bởi vì điều này hiếm khi cần thiết. Có một cách tương đối đơn giản để làm điều này, mặc dù. Sử dụng hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

31 để tìm nạp bảng dịch được sử dụng bởi một trong hai hàm này theo kiểu trích dẫn nhất định. Ví dụ: để lấy bảng dịch mà $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

8 sử dụng, hãy làm điều này

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

1

Để lấy bảng cho $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

10 ở chế độ $output = htmlspecialchars(input, [quote_style, [charset]]);9, hãy sử dụng

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

5

Một mẹo hay là sử dụng bảng dịch này, lật nó bằng cách sử dụng $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

35 và đưa nó vào $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

36 để áp dụng nó vào một chuỗi, do đó thực hiện ngược lại một cách hiệu quả với $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

8

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

3

Tất nhiên, bạn cũng có thể tìm nạp bảng dịch, thêm bất kỳ bản dịch nào khác mà bạn muốn vào đó, sau đó thực hiện $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

36. Ví dụ: nếu bạn muốn $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

8 cũng mã hóa khoảng trắng thành $output = htmlspecialchars(input, [quote_style, [charset]]);3, bạn sẽ thực hiện

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

6

Hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

61 xóa các thẻ HTML khỏi chuỗi

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

8

Hàm có thể lấy một đối số thứ hai chỉ định một chuỗi các thẻ để lại trong chuỗi. Chỉ liệt kê các hình thức mở đầu của các thẻ. Các dạng đóng của thẻ được liệt kê trong tham số thứ hai cũng được giữ nguyên

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

9

Các thuộc tính trong các thẻ được bảo quản không bị thay đổi bởi $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

61. Bởi vì các thuộc tính như $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

63 và $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

64 có thể ảnh hưởng đến giao diện và hành vi của các trang web, nên việc duy trì một số thẻ bằng $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

61 sẽ không nhất thiết loại bỏ khả năng lạm dụng

Hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

66 trả về một mảng các thẻ meta cho trang HTML, được chỉ định dưới dạng tên tệp cục bộ hoặc URL. Tên của thẻ meta (_______567, $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

68, $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

69, v.v. ) trở thành khóa trong mảng và nội dung của thẻ meta trở thành giá trị tương ứng

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

40

Dạng tổng quát của hàm là

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

41

Truyền giá trị $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

80 cho $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

81 để cho phép PHP cố gắng mở tệp bằng đường dẫn bao gồm tiêu chuẩn

PHP cung cấp các hàm để chuyển đổi sang và từ mã hóa URL, cho phép bạn xây dựng và giải mã URL. Thực tế, có hai loại mã hóa URL, khác nhau về cách chúng xử lý khoảng trắng. Đầu tiên (được chỉ định bởi RFC 3986) coi khoảng trắng chỉ là một ký tự không hợp lệ khác trong URL và mã hóa nó thành $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

2. Thứ hai (triển khai hệ thống $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

83) mã hóa một khoảng trắng dưới dạng $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

84 và được sử dụng để xây dựng các chuỗi truy vấn

Lưu ý rằng bạn không muốn sử dụng các chức năng này trên một URL hoàn chỉnh, chẳng hạn như http. //www. thí dụ. com/xin chào, vì chúng sẽ thoát khỏi dấu hai chấm và dấu gạch chéo để tạo

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

42

Chỉ mã hóa một phần URL (bit sau http. //www. thí dụ. com/) và thêm giao thức và tên miền sau

Mã hóa và giải mã RFC 3986

Để mã hóa một chuỗi theo quy ước URL, hãy sử dụng $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

85

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

43

Hàm này lấy một chuỗi và trả về một bản sao có các ký tự URL không hợp lệ được mã hóa theo quy ước $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

86

Nếu bạn đang tạo động các tham chiếu siêu văn bản cho các liên kết trong một trang, bạn cần chuyển đổi chúng bằng $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

85

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

44

Hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

88 giải mã các chuỗi được mã hóa URL

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

45

Các hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

89 và $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

90 chỉ khác với các đối tác thô của chúng ở chỗ chúng mã hóa khoảng trắng dưới dạng dấu cộng ($input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

84) thay vì dưới dạng chuỗi $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

2. Đây là định dạng để xây dựng chuỗi truy vấn và giá trị cookie. Các chức năng này có thể hữu ích trong việc cung cấp các URL giống như biểu mẫu trong HTML. PHP tự động giải mã các chuỗi truy vấn và giá trị cookie, vì vậy bạn không cần sử dụng các hàm này để xử lý các giá trị đó. Các chức năng hữu ích để tạo chuỗi truy vấn

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

46

Hầu hết các hệ thống cơ sở dữ liệu đều yêu cầu ký tự chuỗi ký tự trong các truy vấn SQL của bạn được thoát. Lược đồ mã hóa của SQL khá đơn giản—dấu nháy đơn, nháy kép, NUL-byte và dấu gạch chéo ngược cần phải được đặt trước dấu gạch chéo ngược. Hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

93 thêm các dấu gạch chéo này và hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

94 loại bỏ chúng

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

47

Ghi chú

Một số cơ sở dữ liệu (ví dụ: Sybase) thoát dấu nháy đơn bằng dấu nháy đơn khác thay vì dấu gạch chéo ngược. Đối với những cơ sở dữ liệu đó, hãy bật $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

95 trong php của bạn. tập tin ini

Hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

96 thoát các ký tự tùy ý bằng cách đặt dấu gạch chéo ngược trước chúng. Ngoại trừ các ký tự trong Bảng 4-4, các ký tự có giá trị ASCII nhỏ hơn 32 hoặc cao hơn 126 được mã hóa bằng các giá trị bát phân của chúng (e. g. , $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

97). Các hàm $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

96 và $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

99 được sử dụng với các hệ thống cơ sở dữ liệu không chuẩn có ý tưởng riêng về các ký tự cần thoát

Bảng 4-4. Thoát một ký tự được nhận dạng bởi addcslashes() và stripcslashes()

giá trị ASCII

mã hóa

7

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

400

8

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

401

9

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

402

10

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

403

11

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

404

12

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

405

13

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

406

Gọi $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

96 với hai đối số—chuỗi cần mã hóa và ký tự cần thoát

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

48

Chỉ định một dải ký tự để thoát với cấu trúc $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

408

$input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

49

Cẩn thận khi chỉ định $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

409, $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

410, $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

411, $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

412, $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

413, $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

414, $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

415 hoặc $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

416 trong bộ ký tự, vì chúng sẽ được chuyển thành $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

417, $input = <<< End "Stop pulling my hair!" Jane's eyes flashed.

End; $double = htmlentities($input); // "Stop pulling my hair!" Jane's eyes flashed.&lt;p&gt; $both = htmlentities($input, ENT_QUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p> $neither = htmlentities($input, ENT_NOQUOTES); // "Stop pulling my hair!" Jane's eyes flashed.<p>

418, v.v. Những lần thoát này được C và PHP nhận ra và có thể gây nhầm lẫn

Những ký tự URL nào cần được thoát?

Sử dụng ký tự thoát URL khi tạo URL chứa khoảng trắng hoặc ký tự đặc biệt khác .

Điều gì nên được thoát trong regex?

Chuỗi thoát (\char). Để khớp một ký tự có ý nghĩa đặc biệt trong biểu thức chính quy, bạn cần sử dụng tiền tố chuỗi thoát có dấu gạch chéo ngược ( \ ) . e. g. , \. diêm ". " ; regex \+ khớp với "+" ; và regex \( khớp với "(".

Những ký tự nào nên được thoát trong HTML?

Việc thoát các ký tự HTML trong một chuỗi có nghĩa là thay thế. .
nhỏ hơn ký hiệu (
dấu ngoặc kép (") với "
trích dẫn đơn (') với '
dấu và (&) với &

Ký tự thoát nào có thể được sử dụng?

JavaScript sử dụng \ (dấu gạch chéo ngược) làm ký tự thoát cho. .
\' trích dẫn đơn
\" trích dẫn kép
\\ dấu gạch chéo ngược
\n dòng mới
\r vận chuyển trở lại
thẻ \t
\b xóa lùi
\f nguồn cấp dữ liệu biểu mẫu

Chủ đề