What is the variable interpolation in PHP?

Links for php scripts

Moderators: macek, egami, gesf

User avatar
ifuturzcom
New php-forum User
New php-forum User
Posts: 7
Joined: Mon Mar 26, 2012 1:27 am
Contact:

What is the variable interpolation in PHP?

Postby ifuturzcom » Mon Jun 18, 2012 3:20 am

What is the variable interpolation in PHP?

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: What is the variable interpolation in PHP?

Postby johnj » Mon Jun 18, 2012 7:52 am

$name = "Hello";

echo " $name world";

The output for this will be Hello World. In this case the value for the variable $name was interpolated by php.

patilpallavi
New php-forum User
New php-forum User
Posts: 7
Joined: Wed Jul 04, 2012 11:26 pm

Re: What is the variable interpolation in PHP?

Postby patilpallavi » Wed Jul 11, 2012 4:42 am

variable interpolation only occurs when the string literal is in double-quoted,
but not when it is single-quoted.Below is one simple example

EX :- $name = "Hello";
print "${name} all, have a good day.";

hdmi cables, hdmi Adapters, hdmi Extenders, hdmi Switches

Acesystech
New php-forum User
New php-forum User
Posts: 35
Joined: Mon Aug 20, 2012 10:27 pm
Location: Ernakulam
Contact:

Re: What is the variable interpolation in PHP?

Postby Acesystech » Mon Aug 20, 2012 11:12 pm

php variable interpolation is basically the extraction of the contained value of a given variable.

For example,

Storing "hello" in the scalar* variable $wish,
$wish='hello';

will interpolate properly raw,

echo $wish;

or when double quoted,

echo "She said $wish";

but NOT when single quoted.

echo 'She said $wish'; // prints out: She said $wish


Return to “PHP Scripts”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron