help with displaying

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • john

    help with displaying

    Hi
    I want to display whatever the user has input as it is.
    For eg:
    <?php
    $a="&lt;";
    echo $a;
    ?>
    should output &lt; and not <
    <?php
    $a="<?php?>";
    echo $a;
    ?>
    should output <?php?>

    How to achieve this??
  • Per Gustafsson

    #2
    Re: help with displaying

    john wrote:[color=blue]
    > Hi
    > I want to display whatever the user has input as it is.
    > For eg:
    > <?php
    > $a="&lt;";
    > echo $a;
    > ?>
    > should output &lt; and not <
    > <?php
    > $a="<?php?>";
    > echo $a;
    > ?>
    > should output <?php?>
    >
    > How to achieve this??[/color]

    Try echo htmlentities($a );

    There's also htmlspecialchar s() and some other functions which may be of help.
    Check out the manual, php.net/htmlentities php.net/htmlspecialchar s etc

    /p

    --

    Comment

    • Kevin Thorpe

      #3
      Re: help with displaying

      john wrote:[color=blue]
      > Hi
      > I want to display whatever the user has input as it is.
      > For eg:
      > <?php
      > $a="&lt;";
      > echo $a;
      > ?>
      > should output &lt; and not <
      > <?php
      > $a="<?php?>";
      > echo $a;
      > ?>
      > should output <?php?>
      >
      > How to achieve this??[/color]

      echo htmlentites($a) ;

      Comment

      Working...