Single Quotes Inside Double Quotes Html
Elem innerhtml a href url hello a.
Single quotes inside double quotes html. Single quote marks can be included within the attribute value when the value is delimited by double quote marks and vice versa. W hen using single quotes to create a string literal the single quote character needs to be escaped using a backslash. For instance lets say i have a function called gettable i would expect it to return me a string of html formatted code for a table of data. Single quotes single quotes are the simplest way to make a string.
You can also use double or single quotes inside single quotes. Of course while php knows that something is a variable because it starts with a it doesn t know that htmlspecialchars is a function and treats it as a string. Furthermore inline html is normally an anti pattern. In favor of single quotes.
Photo by priscilla du preez on unsplash double quotes escape. Echo hello a s. Html attributes are usually delimited by double quotes. They just display what they are given no bells and whistles no special powers like being able to show variable values see below in the double quotes section.
I believe you should be building up a string of code and echo out less frequently. Hello world s a world. Elem innerhtml a href url hello a. Well if you just escape the double quotes to and replace back by inside the called js function you can actually allow the contents of the custom html attribute to have single and double.
You should echo each line inidivdually. Not recommended when building sql queries result. Authors may also use numeric character references to represent double quotes and single quotes. You can use double or single quotes inside double quotes.
Whilst variables in double quotes will be evaluated the function in the above is not evaluated and the script produces my answer is htmlspecialchars. Hello world s echo hello world s. And the alert runs. However single quotes are just as legal in html.
For double quotes authors can also use the character entity reference.