Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    851
    Thanks
    172
    Thanked 93 Times in 93 Posts

    where do extra lines come from?

    Hi all

    Does anybody have any idea why I get extra lines at the top of this simple page?

    Note. If I swap the includes for the arrays in the file, everything is fine.


    test.php
    PHP Code:
    include('food.php');
    include(
    'creatures.php');
    echo 
    "test"//a simple test string, no relation to includes
    exit; 

    each simple include is in a separate file which look like this

    PHP Code:
    $creatures = array("cat","mouse","dog","horse","fish"); 
    PHP Code:
    $food = array("hay","cheese","meat","artificial","anything"); 

    output in browser view source

    Code:
    1
    2 
    3 test
    LT
    Last edited by low tech; 08-28-2013 at 10:21 AM.
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    721
    Thanks
    20
    Thanked 84 Times in 84 Posts
    not without knowing what is in
    include('food.php');
    and
    include('creatures.php');

    you probably have whitespace at the top of the files
    Last edited by Arcticwarrio; 08-28-2013 at 01:00 PM.
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • Users who have thanked Arcticwarrio for this post:

    low tech (08-28-2013)

  • #3
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,915
    Thanks
    15
    Thanked 227 Times in 227 Posts
    Do the included files have php tags? They should.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • Users who have thanked DrDOS for this post:

    low tech (08-28-2013)

  • #4
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    851
    Thanks
    172
    Thanked 93 Times in 93 Posts
    @Arcticwarrio

    you probably have whitespace at the top of the files
    Close, turns out white space after closing tag in both files. I completely overlooked that.

    Well done

    Thanks
    LT
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #5
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,248
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by low tech View Post
    Close, turns out white space after closing tag in both files. I completely overlooked that.
    that’s why plain PHP files (e.g. class definitions) often omit the closing PHP tag ?>.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • Users who have thanked Dormilich for this post:

    low tech (08-29-2013)


  •  

    Posting Permissions

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