Tôi có một dòng mã PHP trông như thế này:
echo "$['#edit_errors'].html['Please Correct Errors Before Proceeding
']";
Tôi muốn biết cách thêm màu phông chữ vào văn bản một cách chính xác. Nếu tôi làm điều này:
echo "$['#edit_errors'].html['Please Correct Errors Before Proceeding
']";
Từ "màu đỏ" có trong văn bản màu đen và trình biên dịch đã gây ra lỗi.
Nếu tôi sử dụng các trích dẫn duy nhất xung quanh màu đỏ, thì văn bản hoàn toàn không hiển thị.
Bất kỳ sự trợ giúp nào đều sẽ là tuyệt vời. Cảm ơn
- Trình tự thoát PHP
- Được trích dẫn đơn
- Double Trích dẫn
- Heredoc
- Nowdoc
- Làm thế nào để bạn thoát khỏi một trích dẫn duy nhất?
- Sự khác biệt giữa dấu ngoặc kép đơn và kép trong PHP là gì?
- Php Addslashes là gì?
Trình tự thoát PHP
Được trích dẫn đơn
Double Trích dẫn
Heredoc
Nowdoc
Làm thế nào để bạn thoát khỏi một trích dẫn duy nhất?
Sự khác biệt giữa dấu ngoặc kép đơn và kép trong PHP là gì?
Được trích dẫn đơn
Double Trích dẫn‘’. It is the easiest way to define a string. You can use it when you want the string to be exactly as it is written. All the escape sequences like \r or \n, will be output as specified instead of having any special meaning. Single quotes are usually faster in some cases. The special case is that if you to display a literal single-quote, escape it with a backslash[\] and if you want to display a backslash, you can escape it with another backslash[\\].
Example:
Heredoc
I am a developer. it will be interesting to know about the string. a \ is named as backslash
Double Trích dẫn
Heredoc
Example:
Heredoc
I am a developer. it will be interesting to know about the string. the word is abc
Heredoc
Nowdoc