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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:00:58+00:00 2026-06-05T01:00:58+00:00

What could I use in PHP in place of the normal ‘ and (without

  • 0

What could I use in PHP in place of the normal ' and (without ‘ or “) symbols around something?

Example:

echo("Hello, World!")
  • 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-05T01:00:59+00:00Added an answer on June 5, 2026 at 1:00 am

    There are 4 ways to encapsulate strings, single quotes ', double quotes ", heredoc and nowdoc.

    Read the full php.net article here.

    Heredoc

    A third way to delimit strings is the heredoc syntax: <<<. After this operator, an identifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation.

    http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

    $str = <<<EOD
    Example of string
    spanning multiple lines
    using heredoc syntax.
    EOD;
    

    Nowdoc

    Nowdocs are to single-quoted strings what heredocs are to double-quoted strings. A nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc. The construct is ideal for embedding PHP code or other large blocks of text without the need for escaping. It shares some features in common with the SGML construct, in that it declares a block of text which is not for parsing.

    A nowdoc is identified with the same <<< sequence used for heredocs, but the identifier which follows is enclosed in single quotes, e.g. <<<‘EOT’. All the rules for heredoc identifiers also apply to nowdoc identifiers, especially those regarding the appearance of the closing identifier.

    http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc

    $str = <<<'EOD'
    Example of string
    spanning multiple lines
    using nowdoc syntax.
    EOD;
    

    Escaping

    If you want to use literal single or double quotes within single or double quoted strings, you have to escape them:

    $str = '\''; // single quote
    $str = "\""; // double quote
    

    As Herbert noted, you don’t have to escape single quotes within a double quoted strings and you don’t have to escape double quotes within a single quoted string.


    If you have to add quotes on a large scale, use the addslashes() function:

    $str = "Is your name O'reilly?";
    echo addslashes($str); // Is your name O\'reilly?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I could use PHP to do this, but wanted to find out
I am a absolute PHP n00b, so i could use some help with a
My normal development platform for PHP is Linux. I use a Red hat server
Certain Variables I use acrross Javascript and PHP, for example JSON_ON. I need it
Okay, I'm horrendously new to MySQL and PHP, but could use some help here.
I could use another pair of eyes. This script does what I want in
I could use another set of eyes - perhaps I am missing somehting obvious.
I could use some help with expression conversion. I have a method on a
I could use a bit of help with this, as i am new to
could someone help me with the regex pattern that i could use to match

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.