0

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()`";
Phillip Ngan
  • 15,482
  • 8
  • 63
  • 79
  • https://stackoverflow.com/questions/10758537/php-interpolating-string-for-function-output, https://stackoverflow.com/questions/10002652/in-php-how-to-call-a-function-interpolated-in-string, https://stackoverflow.com/questions/33607468/string-interpolation-for-built-in-functions all potentially answer this already – ADyson Feb 19 '23 at 19:45

0 Answers0