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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:14:13+00:00 2026-06-04T00:14:13+00:00

Possible Duplicate: Is there a performance benefit single quote vs double quote in php?

  • 0

Possible Duplicate:
Is there a performance benefit single quote vs double quote in php?

I am wondering if PHP code takes a performance hit when using "s when defining strings containing no variables, compared to ' where the extra parsing is not performed.

For example, PHP will try to parse variables inside strings defined by " but not '.

$myString = "Greetings earthlings!";
echo '$myString'; //literally outputs the string '$myString'
echo "$myString"; //literally outputs the string "Greetings earthlings"

So my question is, all this time I’ve been writing code like this:

echo "Greetings earthlings";

Have I been wasting cycles? Or is PHP smart/optimized enough to know I really meant:

echo 'Greetings earthlings';

?

  • 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-04T00:14:15+00:00Added an answer on June 4, 2026 at 12:14 am

    A bit of work with VLD tells me that both programs compile to identical bytecode (using PHP 5.3):

    line     # *  op                           fetch          ext  return  operands
    ---------------------------------------------------------------------------------
       2     0  >   ECHO                                                     'Hello+world'
       3     1    > RETURN                                                   1
    

    Conclusion: There’s absolutely no difference in modern versions of PHP. None whatsoever. Use whatever feels best to you.


    There is, however, a difference between echo "Hello $world":

    compiled vars:  !0 = $world
    line     # *  op                           fetch          ext  return  operands
    ---------------------------------------------------------------------------------
       1     0  >   ADD_STRING                                       ~0      'Hello+'
             1      ADD_VAR                                          ~0      ~0, !0
             2      ECHO                                                     ~0
             3    > RETURN                                                   null
    

    And echo "Hello " . $world:

    compiled vars:  !0 = $world
    line     # *  op                           fetch          ext  return  operands
    ---------------------------------------------------------------------------------
       1     0  >   CONCAT                                           ~0      'Hello+', !0
             1      ECHO                                                     ~0
             2    > RETURN                                                   null
    

    I’d hesitate to call that significant, though. The actual real-world difference in performance is, in all probability, trivial.

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

Sidebar

Related Questions

Possible Duplicate: Is there a performance benefit single quote vs double quote in php?
Possible Duplicate: Is there a performance difference between i++ and ++i in C++? I
Possible Duplicate: Is there a performance difference between i++ and ++i in C++? In
Possible Duplicate: Is there a php library for email address validation? Hi there, I
Possible Duplicate: Is there a performance difference between BETWEEN and IN with MySQL or
Possible Duplicate: Is there a workaround for Java's poor performance on walking huge directories?
Possible Duplicate: What is considered fast performance for a single server request? I'm building
Possible Duplicate: Is there a performance difference between i++ and ++i in C++? They
Possible Duplicate: Difference between i++ and ++i in a loop? Is there a performance
Possible Duplicate: Extension Method Performance Will I face performance issues when I´m using extension

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.