我无法执行下面的代码的原因是什么? [重复]

This question already has an answer here:

<?php

$greeting = 'hi';

echo 'hi' $greeting;
?>

I know that the above works when string interpolation is used such as echo "hi $greeting"; but if the code works individually as in echo 'hi' and echo $greeting I don't understand why the I get an error when the code is combined to be echo 'hi' $greeting; as I illustrated above.

</div>

Because that isn't valid code. You need to concatenate the strings if you want to do it like that:

echo 'hi' . $greeting;

You have to replace your code's this part

echo 'hi' $greeting;

to

echo 'hi'.$greeting;