To interpolate a variable into a string in PHP, we simply mention the variable in the string to be output:
$time = time();
print "time=$time";
But is there a way of eliminating the intermediate variable $time
and insert the output of a method time()
into the string using string interpolation? I have tried the following variations unsuccessfully:
print "time=time()";
print "time=$time()";
print "time=${time()}";
print "time=`time()`";