php - Variable inside a string inside array? -



php - Variable inside a string inside array? -

in php, want create array of strings variables, this:

$myarr = array("this $animal.", "something else");

what happens if this:

$animal = "dog"; $myarr = array("this $animal.", "something else"); $animal = "cat"; echo $myarr[0];

will output "this dog." or "this cat."

in other words, variable within string within array change?

after string defined, no longer changes. variable expansion happens @ define-time.

i agree @esqew though have taken sec verify this.

php

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -