Mixing html and php variables inside an echo statement

后端 未结 8 2026
猫巷女王i
猫巷女王i 2020-12-16 06:07

This may be a problem of my trouble with using single and double quotes in one statement. But I have this piece of code:

echo \'
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-16 06:47

    PHP performs what is called variable interpolation on double-quoted strings, which means that the strings are searched for any variables that they might contain, whose values are substituted in the string. If you want to keep the single quotes, you will need to concatenate your strings and variables together like so:

    echo '
    
    ';
    

    Or, if you want to keep the double quotes, you can escape the double quotes that you want to print:

    echo "
    "

提交回复
热议问题