SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Jul 2006
    Location
    Fionnphort, Isle of Mull, Scotland
    Posts
    363
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Could a successful phph 'include' return 'true' ?

    Is it possible that in some circumstances a successful PHP 'include' will return a '1' (true) ?
    I have an irritating '1' turning up on screen and I cannot work out how to get rid of it.

    The code is dead simple:
    <div id="leftcol">
    <?php echo include ("inc/searchbox.html"); ?>
    </div><!-- close leftcol -->

    but I always get this '1' underneath (see image).


    I've searched high and low for a stray '1' in my code, but not found it. It must be something to do with the include, because if I leave out that line, or paste the identical HTML (from 'searchbox.html') into the script instead of the include, there's no '1'.

    I've tried '@include...', and turning error reporting on, but it reveals nothing. Deleting the HTML comment (<!-- close leftcol -->) makes no difference either.

    There must be something I've overlooked; any suggestions, please ?
    Last edited by ramasaig; Oct 21, 2009 at 06:08. Reason: typo in subject line (can't edit it !)
    Tim Dawson
    Isle of Mull, Scotland

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Don't 'echo' the include.

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, include returns a value as documented.

  4. #4
    SitePoint Addict
    Join Date
    Jul 2006
    Location
    Fionnphort, Isle of Mull, Scotland
    Posts
    363
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Guido2004: Thanks. I feel unbelievably stupid, I just didn't see that I'd put the echo in !!

    crmalibu: That's what I thought, but I'd never seen it printed out before.

    Just goes to show you often can't see the wood for the trees.
    Tim Dawson
    Isle of Mull, Scotland

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    a.php:
    PHP Code:
    <?php return array( 'cat' => 'mew''dog' => 'arf' );
    b.php:
    PHP Code:
    $a = include 'a.php';
    var_dump$a ); 
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •