Re: backslashes added to quotes when reading from form

From: Oli Filth (oli_filth_at_eatspam.coldmail.com)
Date: 12/04/04

  • Next message: Oli Filth: "Re: array in PHP"
    Date: Sat, 04 Dec 2004 04:32:29 GMT
    
    

    Think about what's going on here! The print command sends the contents of
    $comment straight to the browser. You're not asking PHP to evaluate/execute the
    contents (e.g. by using eval()), so even if it contains PHP code, it won't be
    executed at the server.

    The browser receives the contents of $comment and tries to interpret it as HTML.
    So anything that was HTML in the original file will appear as you'd expect (i.e.
    formatted), and anything in PHP tag delimiters (i.e. <?php ... ?>) is
    interpreted as an unknown HTML tag and hence is not displayed.

    Oli

    paul wrote:
    > Oh no they support php, it's just when I post the contents of a text
    > file containing some php code, it is not interpreted. This is the code I
    > extract it with:
    >
    > # extract comments from text file to screen
    > if (file_exists ("$basename.txt")){
    > $comment = file_get_contents("$basename.txt");
    > print $comment;
    > }
    >
    > If the content is:
    >
    > <?php print "hello"; ?>
    >
    > it comes up blank, though I thought before it printed out that code
    > verbatim.
    >
    > html code like test does get interpreted as html
    > though.
    >
    >
    > Harrie Verveer wrote:
    >
    >> if you used <? as open tag, try using <?php
    >>
    >> if that doesn't work, I'm afraid your hosting provider doesn't support
    >> PHP :(
    >>
    >> paul wrote:
    >>
    >>> Interestingly, I tried putting some php code in my form and it didn't
    >>> execute. The html code gets properly formatted but the php just comes
    >>> out as raw text.


  • Next message: Oli Filth: "Re: array in PHP"

    Relevant Pages

    • Re: how to run scripts after a page has already loaded and been sent to a users browser?
      ... > It's because PHP is a server side scripting language, ... > do stuff before you send stuff to user's web browser. ... As we've discussed on this newsgroup before, if a script starts ... that is after the last HTML is sent to a web browser. ...
      (alt.php)
    • Re: How do we get there from here?
      ... Unlike my dislike for PHP, my dislike for SQL is based on ... >>> up with at least html and php quite mixed into each other, ... Using a PHP script to send HTML ... code to a browser in no way taints that code. ...
      (comp.databases.pick)
    • Re: Form spam? What to do?
      ... >>> You will notice a php include at the top of the code. ... one example of a browser with such an Accept ... On contrast IE6 accepts the html 4.01 strict code as you can ... it has built in changes to process the true xhtml ...
      (alt.html)
    • Re: Browser Compatibility issues
      ... PHP is not the cause. ... PHP just outputs HTML ... browser and which features are implemented and which not differs per ...
      (comp.lang.php)
    • Re: Function execution before page reload
      ... I have a function that loads a page and the action is ... ALL code is executed before the page is sent to the browser. ... Interaction between PHP and the browser is one-way - the PHP sends the page and terminates. ... There isn't any interaction between the browser and the PHP code. ...
      (comp.lang.php)