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

  • SEARCH
  • Home
  • 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 6711829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:11:15+00:00 2026-05-26T08:11:15+00:00

I want to give a text to a DIV. This text has HTML tags,

  • 0

I want to give a text to a DIV. This text has HTML tags, so I thought its enough to escape the ” and ‘ characters. Full code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
</head>
<body>
<div id="lay">.</div>
<?php
 $a = 'Missing<hr />argument 3 for Class::method(), called in X:\directory\dir2\dir3\x';
 $a = str_replace(array("\"", "'"), array("&quot;", '&#039;'), $a);
?>
<script type="text/javascript">
 document.getElementById('lay').innerHTML = '<?php echo $a; ?>';
</script>
</body>
</html>

but firefox said its malformed. Even htmlspecialchars() aint work. How the heck to escape this string? And why it fails?

  • 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-26T08:11:15+00:00Added an answer on May 26, 2026 at 8:11 am

    Just use addslashes like so:

     $a = 'Missing<hr />argument 3 for Class::method(), called in X:\directory\dir2\dir3\x';
     $a = addslashes($a);
     $a = str_replace(array("\"", "'"), array("&quot;", '&#039;'), $a);
    

    As the documentation says:

    Returns a string with backslashes before characters that need to be
    quoted in database queries etc. These characters are single quote (‘),
    double quote (“), backslash () and NUL (the NULL byte).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to give a static javascript block of code to a html template
In my application I want to give the user ways of selecting text from
I want to give integer input to Ruby like this: 12 343 12312 12312
I want to give default value to a textarea. The code is something like
I created a graph using html, now I want to give it a nice
Basically, I want an outer DIV's height to be dictated by its inner DIVs
I want the div to be exactly in the center horizontally. I've tried this:
This question has been asked before, but none that I have reviewed give a
I want to give a user access to a stored procedure, but not to
I want to give zoom effect to the iPhone camera image while capturing the

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.