How to display PHP & HTML source code on a page?

后端 未结 8 2105
悲&欢浪女
悲&欢浪女 2020-11-30 14:20

How would one go about showing PHP code on user end. Sort of like w3School does?

Having lets say a grey area div, and then showing the code in there without activati

8条回答
  •  野性不改
    2020-11-30 15:10

    The PHP code will just be a string that you can echo or print onto the page, no different than any other data you want PHP to display for you. If you want to keep the formatting (ex. the indentation), put it inside a

     block.

    Ex:

    $php_code = '';
    
    echo "
    $php_code
    ";

提交回复
热议问题