SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Snellville
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem including a file

    I am a PHP newbie, but learning quickly.

    I use include to display the header and footer for my website.

    The name of the header file is header.inc

    In my index.php file, I have

    Code:
    include (header.inc);
    But it will not display, instead I get an error message saying there is no file called headerinc. Thats right, it is removing the period inbetween header and inc.

    What would cause this?

    The only way I can make includes work, is to name the file with no extension.

    I renamed it to just header, and it works file when I tell it to include header, but if I give it a name with an extension, it will not work.

    Any ideas?

  2. #2
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    Southwest US
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Place quotation marks around the file name. Such as:
    include ("header.inc");

  3. #3
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Snellville
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That fixed it, but why would not having the " marks around it cause apache to rewrite the filename without the period?

  4. #4
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can also use

    PHP Code:
     
    include('filename.php'); 

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Madison, WI
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    because otherwise php is treating the . as a concactanation operator and simply combines the two strings on either side of it

  6. #6
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Snellville
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jinkas
    because otherwise php is treating the . as a concactanation operator and simply combines the two strings on either side of it
    Ah, I understand now.

    Thanks guys, for the speedy response.


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
  •