[PHP] Is a file included?

Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    Ginger by design. jMerliN is offline
    MemberRank
    Feb 2007 Join Date
    2,497Posts

    Re: [PHP] Is a file included?

    Quote Originally Posted by AngraMainyu View Post
    In PHP, associative arrays are implemented as hash tables. Any operation that does not involve iteration is O(1).
    I know. I was saying that include_once is likely implemented as a hash table, whereas the proposals here involve looping through loaded files to check. O(1) vs O(n).

  2. #17
    Account Upgraded | Title Enabled! AngraMainyu is offline
    MemberRank
    May 2011 Join Date
    445Posts

    Re: [PHP] Is a file included?

    Quote Originally Posted by jMerliN View Post
    I know. I was saying that include_once is likely implemented as a hash table,
    I wasn't disagreeing, only confirming.

    Quote Originally Posted by jMerliN View Post
    whereas the proposals here involve looping through loaded files to check. O(1) vs O(n).
    I should also mention that if the OP checks every include against the list of successfully loaded includes, they're looking at O(n^2) performance, not to mention the performance cost of doing so recursively. O(n) isn't the least of the OP's worries.

  3. #18
    Enthusiast redster is offline
    MemberRank
    Sep 2011 Join Date
    USALocation
    37Posts

    Re: [PHP] Is a file included?

    core coders :D

  4. #19
    hi i'm robbie Roper is offline
    MemberRank
    Oct 2008 Join Date
    /home/roperLocation
    2,283Posts

    Re: [PHP] Is a file included?

    Such a simple snippet, cheers Jonty!



Page 2 of 2 FirstFirst 12

Advertisement