You always want to HTML-encode things inside HTML attributes, which you can do with htmlspecialchars
:
<span title="<?php echo htmlspecialchars($variable); ?>">
You probably want to set the second parameter ($quote_style
) to ENT_QUOTES
.
The only potential risk is that $variable
may already be encoded, so you may want to set the last parameter ($double_encode
) to false
.
Related Contents:
- HTML,PHP – Escape ” symbols while echoing
- something wrong with replace string? [closed]
- No response to update query in oracle [closed]
- Grabbing the href attribute of an A element
- How to extract img src, title and alt from html using php? [duplicate]
- How do you parse and process HTML/XML in PHP?
- How to retrieve images from MySQL database and display in an html tag
- How can I echo HTML in PHP?
- Parse error: Syntax error, unexpected end of file in my PHP code
- dynamic drop down box?
- Seo Friendly URL results in CSS IMG and JS not working
- PHP: How do you determine every Nth iteration of a loop?
- How to escape strings in SQL Server using PHP?
- HTML/PHP – Form – Input as array
- Can HTML be embedded inside PHP “if” statement?
- How to remove both .php and .html extensions from url using NGINX?
- How do I get the HTML code of a web page in PHP?
- How can I replace newline or \r\n with ?
- Escaping single quote in PHP when inserting into MySQL [duplicate]
- Submit an HTML form with empty checkboxes
- Fetching data from MySQL database to html dropdown list
- Why is PDO better for escaping MySQL queries/querystrings than mysql_real_escape_string?
- How to parse HTML in PHP?
- HTML Scraping in Php [duplicate]
- How to force a file to download in PHP
- Can you put PHP inside PHP with echo? [closed]
- How to embed images in html email
- PHP POST not working
- jQuery AJAX form using mail() PHP script sends email, but POST data from HTML form is undefined
- PHP quotes inside quotes
- Equivalent of include() in HTML
- Convert PDF to HTML [closed]
- Dynamic table in HTML using MySQL and php
- How can we open a link in private browsing mode
- Creating dynamic tables in HTML using MySQL and PHP
- PHP HTML DOMDocument getElementById problems
- Send email with PHPMailer – embed image in body
- Using php to output an mp4 video
- php: Get html source code with cURL
- How to get int instead string from form?
- PHP Upload, extract and progressbar
- Do I need to escape backslashes in PHP?
- How to display XML in HTML in PHP?
- How to embed images in a single HTML / PHP file?
- Count and limit the number of files uploaded (HTML file input)
- Convert .doc to html in php [closed]
- Capture newline from a textarea input
- How can I view/open a word document in my browser using with PHP or HTML
- HTML Form POST to PHP page [closed]
- How to save webpage as a image file using PHP?