a question about includes

Discussion in 'PHP' started by sawz, Jul 19, 2007.

  1. #1
    i used an include to include a php script.
    but there is the number 1 displaying next to my include.

    you can see it here, the numbers are on the left:
    http://www.american-builder.com/db/quote/quote-test.php

    why are those numbers there and how do i get rid of them please?
     
    sawz, Jul 19, 2007 IP
  2. chikabc

    chikabc Peon

    Messages:
    19
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can we see the include line?

    I know that when successfull, include returns true which resolves to 1 when printed
     
    chikabc, Jul 19, 2007 IP
  3. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #3
    just a simple include?

    <?php
    echo
    include( "index.php" );
    ?>
    Code (markup):
     
    sawz, Jul 19, 2007 IP
  4. mrmonster

    mrmonster Active Member

    Messages:
    374
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #4
    You're probably doing something like:

    print include('foo.php');

    Which will print 1 and show the includes content if it finds the file.

    Remove the print statement.
     
    mrmonster, Jul 19, 2007 IP
    sawz likes this.
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    include returns true by default on success. True has the value of 1, and you're echoing the include. That's where the 1 comes from. Just remove the echo, which is not necessary here, and it'll work.
     
    nico_swd, Jul 19, 2007 IP
    sawz likes this.
  6. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #6
    thanks, i appreciate you taking the time to educate me.
    rep for all who posted.
     
    sawz, Jul 19, 2007 IP
  7. chikabc

    chikabc Peon

    Messages:
    19
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    do this instead

    <?php

    include( "index.php" );
    ?>
     
    chikabc, Jul 19, 2007 IP
    sawz likes this.