Why is my font color not working in this PHP script?

Patricia Arquette
Release: 2024-11-11 15:36:03
Original
214 people have browsed it

Why is my font color not working in this PHP script?

Double Quotes within PHP Script Echo

Question

A PHP code is provided:

echo "<script>$('#edit_errors').html('<h3/><em/>Please Correct Errors Before Proceeding</h3>')</script>";
Copy after login

The user seeks to add a font color to the text. However, upon attempting the following:

echo "<script>$('#edit_errors').html('<h3/><em/><font color=\"red\">Please Correct Errors Before Proceeding</h3>')</script>";
Copy after login
Copy after login

The word "red" appears in black, and the compiler generates an error. Single quotes unsuccessfully hide the text.

Answer

Double quotes are misinterpreted as the string's end. To escape this, use backslash () to escape the quotation mark:

echo "<script>$('#edit_errors').html('<h3/><em/><font color=\"red\">Please Correct Errors Before Proceeding</h3>')</script>";
Copy after login
Copy after login

Consult the documentation for further information on strings and escape sequences.

The above is the detailed content of Why is my font color not working in this PHP script?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template