dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: What is the variable interpolation in PHP?

Hybrid View

  1. #1
    Join Date
    May 2013
    Posts
    119

    What is the variable interpolation in PHP?

    Hello Guys,
    Please let me help to know that What is the variable interpolation in PHP? please share you feedback on this.
    Thank for any reply.

  2. #2
    Join Date
    Feb 2012
    Location
    Pensacola, FL
    Posts
    309
    Is this a question you have on homework?

    Variable interpolation is basically just using a variable in a string or expression.

    Example:
    PHP Code:
    $first_name "John";
    $last_name "Doe";

    $fn_count strlen($first_name);
    $ln_count strlen($last_name);

    echo 
    "Hello {$first_name} {$last name}.  Your first name contains {$fn_count} character and your last name contains {$ln_count} characters."

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    20,044
    PHP supplies many ways to use variables within strings, including interpolation within double-quoted and "heredoc" strings. Read all about it in the manual page on the string type.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

  4. #4
    Join Date
    Jun 2013
    Posts
    1
    In computer programming, variable interpolation is the process of evaluating an expression or string literal containing one or more variables, yielding a result in which the variables are replaced with their corresponding values in memory. It is a specialized instance of concatenation.

    Languages that support variable interpolation include Perl, PHP, Ruby, Tcl, Groovy, and most Unix shells. In these languages, variable interpolation only occurs when the string literal is double-quoted, but not when it is single-quoted. The variables are recognized because variables start with a sigil (typically "$") in these languages.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles