SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    recursive includes

    hello,
    I saw some thing I don't understand: a.php includes b.php, b.php includes c.php, then c.php comes to include a.php. That is: a.php->b.php->c.php->a.php.
    Will this kind of circular includes cause indefinite load? How does web server work this kind of resursive includes?
    Thanks,
    Charlie

  2. #2
    SitePoint Zealot Mau's Avatar
    Join Date
    Jan 2006
    Location
    California, USA
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try it and see for yourself:
    PHP Code:
    <?php
    echo 'Awesomeness!';
    include(
    __FILE__);
    (Yes, it creates an infinite loop).

  3. #3
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    php will usually error out telling you that the class, function, variable or something else has already been defined. Liek joebert mentioned, use include_once()
    intragenesis, llc professional web & graphic design


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
  •