Help Please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AuXiLiRY
    New Member
    • Mar 2004
    • 15
    • 3.0.3

    Help Please

    I don't know how to do this. I am trying to get php to echo php code as code and not parse it as php. For example:

    PHP Code:
    <?php
     
    echo "<?php echo "test"; ?>";
     
    ?>
    I want that whole line <b><?php echo "test"; ?></b> to be displayed, not parsed as php. Any ideas? Probably a simple thing, im a newbie.
    Last edited by AuXiLiRY; Tue 30 Mar '04, 7:17pm.
  • daemon
    Senior Member
    • Jun 2003
    • 2351
    • 3.5.x

    #2
    You need to use convert it into HTML entities to do this.

    You can try this with htmlspecialchars() to convert all non-standard characters to HTML ones.

    Here's an example:

    PHP Code:
    <?php


    echo(htmlspecialchars('<?php echo("foo"); ?>'));


    ?>
    Last edited by daemon; Tue 30 Mar '04, 7:16pm.
    Bugdar: PHP bug tracking software that is beautiful, fast, and robust.

    Comment

    • AuXiLiRY
      New Member
      • Mar 2004
      • 15
      • 3.0.3

      #3
      Thanks a lot!

      Comment

      • MarcHanlon
        New Member
        • Nov 2001
        • 17

        #4
        Or you could have PHP do all the leg work and even give your source highlighting:

        PHP Code:
          highlight_string('<?php echo("foo"); ?>');
        Note: You don't need echo because highlight_string echoes automatically. See the documentation for more.
        Last edited by MarcHanlon; Wed 31 Mar '04, 1:59am. Reason: Adding sig
        Marc Hanlon
        Rushland.net

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...