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 9218841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:57:27+00:00 2026-06-18T02:57:27+00:00

I am confused about using single and double quotes and back slash while using

  • 0

I am confused about using single and double quotes and back slash while using java script and html tags in php can any one please clarify i googled it but still not clear about it. i am confused for this small thing.i am new to programming
– here is my code

 <?php
if(isset($_GET['id'])) {
echo '<div id="d2">';
include "test2.php";
 echo '</div>'; }
 else
 { 
  echo '<div id="d1">';
 include "insert.php";
 print "<script type=javascript>"
 print "document.getEelementById('alertdiv1').innerHTML='hi' ;"
 print "</script>"
echo '</div>';
     }
?>
  • 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-06-18T02:57:28+00:00Added an answer on June 18, 2026 at 2:57 am

    In PHP, you can enclose a string in either single quotes or double quotes. Both are valid:

    $var = "this is a string";
    $var2 = 'this is also a string';
    

    The main difference is that if your string contains a variable, and you want the variable content to be treated as part of the string, you need to use double quotes:

    echo "$var which I made";
    

    will return:

    this is a string which I made

    When you are manipulating html, css and JavaScript strings, you need to make sure that you don’t accidentally close your PHP string. For example:

    echo "<h1 class='myheading'>Heading Text</h1>";
    

    Notice how I used double quotes to enclose my string? Because I did that, I was able to use single quotes in the html, without escaping them.

    If I’d wanted to use double quotes in my string, I would have had to escape them, like this:

    echo "<h1 class=\"myheading\">Heading Text</h1>";
    

    The \ tells PHP that the double quote which immediately follows is to be treated as a literal, and not used to terminate the string.

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

Sidebar

Related Questions

I am confused about using php or python for implementing server program . I
I'm a bit confused about using STL set::find() for a set of my own
I'm confused about the correct way of using asynchronous socket methods in C#. I
I am using a UITextView and I am confused about making the keyboard to
I'm new to SVN and I'm quite confused about a problem. I am using
I am a little confused about the roles of a java application server and
I'm confused about whether it is better to use a single top-level headline for
I'm a bit confused about proper usage of svn in case of a single
so I have started using Subversion and am confused about the ignore files. From
I'm using java for about a month, and still am generally an amateur in

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.