In PHP, can i use put echo inside a variable?

This question already has an answer here:

  • PHP parse/syntax errors; and how to solve them? 13 answers

  •  <!DOCTYPE HMTL>
    <html>
    <head>
    </head>
    <body>
    <?php
    echo $javascript = '<script type = "text/javascript">prompt("Hello");</script>';
    ?>
    </body>
    </html>
    

    You can simply echo the script using echo (without even using the variable)

    <?php
    echo '<script type = "text/javascript">prompt("Hello");</script>';
    ?>
    

    Or Using variable

    <?php
    echo $javascript = '<script type = "text/javascript">prompt("Hello");</script>';
    ?>
    

    Or using shorthand

    <?='<script type = "text/javascript">prompt("Hello");</script>'?>
    
    链接地址: http://www.djcxy.com/p/59452.html

    上一篇: 即使没有缺失的分号。?

    下一篇: 在PHP中,我可以在变量中使用put echo吗?