+ Reply to Thread
Results 1 to 6 of 6

Thread: php doing things recursively

  1. #1
    hero080 is offline x10Hosting Member hero080 is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    16

    php doing things recursively

    Code:
    <?php
    $str = "<?php";
    echo $str;
    ?>
    I expected to see "<?php" as the output. However, the output seems to be interpreted as php code and executed again by the server and at the end I get nothing for output.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: php doing things recursively

    When you run the page, look at the source (ie 'View Source" )

    The output is there. Just not visible due to the fact the browser thinks < is starting an html tag and does not display it.
    Nothing is always absolutely so.

  3. #3
    hero080 is offline x10Hosting Member hero080 is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    16

    Re: php doing things recursively

    You should be correct, and what you said is exactly what I thought.
    However, by viewing the source of the page, I found nothing there.

    Nonetheless, your way did work. Use &lt; to replace the < did solve this problem.

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: php doing things recursively

    Interesting, which browser do you use?
    FireFox shows a blank page, but the source reveals the output.
    IE8 shows the output as text
    Chrome seems to show nothing in display or source.
    Nothing is always absolutely so.

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: php doing things recursively

    Chrome appears to strip XML processing instructions, even when displaying an unrendered view of the response body.

    Code:
    <?foo ?>bar<?qux quux?>
    If you set the content type to "text/plain", you'll see everything.

    PHP Code:
    <?php header('Content-type: text/plain'); $fmt='<?php header(\'Content-type: text/plain\'); $fmt=\'%s\'; printf($fmt, addcslashes($fmt, \'\\\'\\\\\')); ?>'printf($fmtaddcslashes($fmt'\'\\')); ?>
    Also, Chrome will display output in the source view after a "?>".
    PHP Code:
    <?php $fmt='<?php $fmt=\'%s\'; printf($fmt, addcslashes($fmt, \'\\\'\\\\\')); ?>'printf($fmtaddcslashes($fmt'\'\\')); ?>
    Last edited by misson; 04-06-2010 at 08:54 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  6. #6
    hero080 is offline x10Hosting Member hero080 is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    16

    Re: php doing things recursively

    That's it. I was using chrome.
    Now I know that "viewing source" won't necessarily give me the real source. Chrome the cheater!

+ Reply to Thread

Similar Threads

  1. i wonder some things..
    By chrille1 in forum Free Hosting
    Replies: 1
    Last Post: 09-23-2008, 05:37 PM
  2. Need to know a few things.
    By rockraider in forum Free Hosting
    Replies: 2
    Last Post: 10-04-2007, 12:04 PM
  3. Two things...
    By Matt in forum Free Hosting
    Replies: 0
    Last Post: 03-30-2006, 06:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers