How do I use single quotes inside single quotes?

前端 未结 7 1989
梦谈多话
梦谈多话 2020-12-31 14:10

Can anyone explain how to make this code work?

echo \'
Welcome
\'
7条回答
  •  感情败类
    2020-12-31 14:19

    Generally speaking, to use the single quote inside a string that is using the single quote as delimiter, just escape the single quote inside the string

    echo 'That\'s all, folks';
    

    It's not clear what the purpose of your code is, though.

    echo '
    Welcome
    ';

    As you are already using PHP code, is not necessary. If you are only trying to output the content of a session variable, then you can use

    echo '
    Welcome ' . $_SESSION['username'] . '
    ';

提交回复
热议问题