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?
- you're missing
=sign in variable assignment - you have string in single quotes keeps variable being interpolated
.
$now = new datetime(); $year = $now->format("y"); echo "hello world, year $year";
Comments
Post a Comment