SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,157
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post when to use this

    Hi,can anyone enlighten my mind,when should i use the include_once and the required_once..and what is the difference on this two.Thank you in advance.

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2012
    Location
    Scarborough, North Yorkshire, United Kingdom
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You would use them to include another file. A common example is to use include_once('header.php') on each page, so you just have to maintain one header file (Makes it easier to add/remove links).

    They both essentially do the same thing but if you use require, the file HAS to be available or you receive a fatal error whereas include_once will try to include it but if it can't find it the page will still render.

    http://stackoverflow.com/questions/3...require-in-php

  3. #3
    SitePoint Guru bronze trophy TomB's Avatar
    Join Date
    Oct 2005
    Location
    Milton Keynes, UK
    Posts
    996
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    In practice, if you're trying to include a file which doesn't exist then you're probably doing something wrong. In most cases, you'll want to use Require.

  4. #4
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,157
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    @TomB @RichardAskew, .Thank you for the reply and i will write it again if i have in doubt.


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
  •