string problem

Discussion in 'PHP' started by freiza, Jul 13, 2010.

  1. #1
    //********************my.php
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
            <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
            <meta name="author" content="freiza" />
    
            <title>Untitled 2</title>
    </head>
    
    <body>
    
    <?php 
    print "<form action='run.php' method='get' enctype='text/plain'>
    <input type=\"text\" name=\"one\" />
    <input type=\"submit\" />
    </form>
    ";
    ?>
    
    </body>
    </html>
    
    
    //********************************run.php
    <?php
    
    /**
     * @author freiza
     * @copyright 2010
     */
    print $_GET['one']." world";
    
    
    ?>
    
    Code (markup):

    when i execute i get hello world...
    Is there any way that i can get only hello and omit "world" without modifying run.php
     
    freiza, Jul 13, 2010 IP
  2. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Strange request, but possible.

    Add this to the very top:
    <?php
        ob_start();
    ?>
    Code (markup):
    And then this to the very bottom (under 'run.php'):
    <?php
        echo substr_replace(ob_get_clean(), '', -7);     
        ob_end_clean(); 
    ?>
    Code (markup):
     
    Deacalion, Jul 13, 2010 IP
  3. freiza

    freiza Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    but i already mentioned not to touch run.php in anyway.
    it would be rather easy to omit the word "world" . if run.php were to be accessed.
    thanx..(I am happy)...


    But please find a way...(urgent)
     
    freiza, Jul 13, 2010 IP
  4. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ok. Put that code under run.php. Not in it.
     
    Deacalion, Jul 13, 2010 IP