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
Post a Comment