date - Use of DateTime in PHP echo -


i have set variables display current year this:

$now = new datetime(); $year $now->format("y"); 

i using echo this:

echo $str='hello world, year $year'; 

this not displaying year however, doing wrong?

  1. you're missing = sign in variable assignment
  2. you have string in single quotes keeps variable being interpolated

.

$now = new datetime(); $year = $now->format("y"); echo "hello world, year $year"; 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -