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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:06:02+00:00 2026-05-27T21:06:02+00:00

I just noticed that I could use an a variable as an argument, like

  • 0

I just noticed that I could use an a variable as an argument, like this: $variable = "This's a string."; function('$variable'), and not like this: function('This's a string');. I can see why I can’t do the latter, but I don’t understand what’s happening behind the scenes that meakes the first example work.

  • 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-27T21:06:02+00:00Added an answer on May 27, 2026 at 9:06 pm

    Have you heard about formal languages? The parser keeps track of the context, and so, it knows what the expected characters are and what not.

    In the moment you close the already opened string, you’re going back to the context before the opening of the string (that is, in the context of a function call in this case).

    The relevant php-internal pieces of codes are:

    • the scanner turns the sequence between ‘ and ‘ into an indivisible TOKEN.
    • the parser puts the individual indivisible tokens into a semantic context.

    These are the relevant chucks of C code that make it work. They are part of the inner workings of PHP (particularily, the Zend Engine).

    PHP does not anticipate anything, it really reads everything char by char and it issues a parsing error as soon as it finds an unexpected TOKEN in a semantic context where it’s not allowed to be.

    In your case, it reads the token 'This' and the scanner matches a new string. Then it goes on reading s and when it finds a space, it turns the s into a constant. As the constant and the previously found token 'This' together don’t form any known reduction (the possible reductions are described in the parser-link I’ve given you above), the parser issues an error like

    Unexpected T_STRING

    As you can deduce from this message, it is really referring to what it has found (or what it hopes it has found), so there’s really no anticipation of anything.

    Your question itself is wrong in the sense that there’s no apostroph in the variable (in the variable’s identifier). You may have an apostroph in the variable’s value. Do not confuse them. A value can stand alone, without a variable:

    <?php
    'That\'s fine';
    42;
    

    (this is a valid PHP code which just loads those values into memory)

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

Sidebar

Related Questions

I just noticed that you can not use standard math operators on an enum
I just noticed that you can do this in C#: Unit myUnit = 5;
I just noticed that java.beans.Introspector getBeanInfo does not pickup any superinterface's properties. Example: public
I have just noticed that a multidimensional array in C# does not implement IEnumerable<T>
I just noticed that I can do the following, which came as a complete
Just noticed that the style of the navigation menu on windows.com is just what
I just noticed that the return list for results is limited to 1000. I
I just noticed that Chromium was installed in AppData in both Vista and XP.
I just noticed that say http://s7.addthis.com/js/250/addthis_widget.js#pub=PUBID does the equivalent of http://s7.addthis.com/js/250/addthis_widget.js?pub=fct-250 but is much
I just noticed that for vector push_back it is push back a reference to

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.