Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3312708
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:01:38+00:00 2026-05-17T22:01:38+00:00

I have code loading in the titles of some films into the title attribute

  • 0

I have code loading in the titles of some films into the title attribute of their respective thumbnails, this format is thus:

Artist Name – ‘Song Title’

I had this code initially:

$return .= "' title='";
$return .=$video['title'];
$return .= "'>";

Obviously the first single quote was causing the title attribute to end prematurley, so I changed it to:

$return .= "' title='";
$return .= htmlspecialchars($video['title']);
$return .= "'>";

Which has had not effect at all, all the titles are still ending prematurely.

Am I misunderstanding the htmlspecialchars method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:01:39+00:00Added an answer on May 17, 2026 at 10:01 pm

    http://php.net/manual/en/function.htmlspecialchars.php

    By default, htmlspecialchars() does not escape single quotes (some ancient compatibility behavior). Use htmlspecialchars($video['title'], ENT_QUOTES).

    You also probably should pass ‘utf-8’ as the third argument. I wrapped this deprecated behavior like this:

    function htmlencode($str, $nl2br = false, $nbsp = false)
        {
        $str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8', true);
        if ($nbsp)
            {
            $str = str_replace(" ", ' ', $str);
            }
        if ($nl2br)
            {
            $str = nl2bruni($str);
            }
        return $str;
        }
    
    /**
        PHP's built-in nl2br() only works with LF newlines. This version also works with CR+LF, CR and RS
    */
    function nl2bruni($str)
        {
        return preg_replace('{\\r?\\n|\\r|\\x1e}', '<br />', $str);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently come across a situation where code is dynamically loading some libraries,
I have code similar to this filtering entries in an Array of Objects: var
I have code like this: var newMsg = new Msg { Var1 = var1,
I have code like this: template <typename T, typename U> struct MyStruct { T
I have code like this to move the player in my game left, right,
I have the following code which is loading an xml file to populate a
I'm trying to run some tests on some Ajax code we have written, now
I have this code that I run when a user submits a form (this
I am loading some images dynamically into a UITableView and creating some simple custom
I have a following code: $(document).ready(function() { $('a[rel]').each(function() { $(this).qtip( { content: { text:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.