PHP includes question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nu

    PHP includes question

    If my index.php has two includes:

    require_once( './includes/WebStart.php' );
    require_once( "includes/Wiki.php" );


    Then each of those have includes, then each of those...... etc. etc.
    etc..........

    Once index.php is called, even if it aborts (not from an error but say by
    the program's own design), do every single one of my thousands of PHP
    interlinked files by "require_on ce" lines get all loaded, compiled, and put
    into memory?



  • Nu

    #2
    Also... Re: PHP includes question


    "Nu" <no@spam.comwro te in message
    news:jbgwh.4910 37$Fi1.188266@b gtnsc05-news.ops.worldn et.att.net...
    If my index.php has two includes:
    >
    require_once( './includes/WebStart.php' );
    require_once( "includes/Wiki.php" );
    >
    >
    Then each of those have includes, then each of those...... etc. etc.
    etc..........
    >
    Once index.php is called, even if it aborts (not from an error but say by
    the program's own design), do every single one of my thousands of PHP
    interlinked files by "require_on ce" lines get all loaded, compiled, and
    put
    into memory?
    >
    >
    >



    Also, does it matter if I put "require_on ce" lower down in the code after
    some other code my abort it?




    Comment

    • Sanders Kaufman

      #3
      Re: Also... Re: PHP includes question

      Nu wrote:
      Also, does it matter if I put "require_on ce" lower down in the code after
      some other code my abort it?
      No - and you may find this weird.
      An include/require will be included no matter what.

      For example:
      <? php
      if(TRUE){
      include "myfile.php ";
      } else {
      include "yourfile.p hp";
      }
      ?>

      In the above example - BOTH files will be included no matter what.

      Comment

      • Nu

        #4
        Re: Also... Re: PHP includes question

        "Sanders Kaufman" <bucky@kaufman. netwrote in message
        news:Klgwh.2288 $4H1.1860@newss vr17.news.prodi gy.net...
        Nu wrote:
        >
        Also, does it matter if I put "require_on ce" lower down in the code
        after
        some other code my abort it?
        >
        No - and you may find this weird.
        An include/require will be included no matter what.
        >
        For example:
        <? php
        if(TRUE){
        include "myfile.php ";
        } else {
        include "yourfile.p hp";
        }
        ?>
        >
        In the above example - BOTH files will be included no matter what.
        Okay, but both files have include/requires. Will their include/requires be
        included, too?



        Comment

        • Nu

          #5
          Re: Also... Re: PHP includes question


          "Sanders Kaufman" <bucky@kaufman. netwrote in message
          news:Klgwh.2288 $4H1.1860@newss vr17.news.prodi gy.net...
          Nu wrote:
          >
          Also, does it matter if I put "require_on ce" lower down in the code
          after
          some other code my abort it?
          >
          No - and you may find this weird.
          An include/require will be included no matter what.
          >
          For example:
          <? php
          if(TRUE){
          include "myfile.php ";
          } else {
          include "yourfile.p hp";
          }
          ?>
          >
          In the above example - BOTH files will be included no matter what.


          I have seen code like this:

          if ( file_exists( "$IP/languages/classes/$class.deps.php " ) ) {
          include_once("$ IP/languages/classes/$class.deps.php ");
          }


          It appears not to load the file unless an if statement passes.


          Comment

          • Sanders Kaufman

            #6
            Re: Also... Re: PHP includes question

            Nu wrote:
            "Sanders Kaufman" <bucky@kaufman. netwrote in message
            >In the above example - BOTH files will be included no matter what.
            >
            Okay, but both files have include/requires. Will their include/requires be
            included, too?
            Yeah - that's why the require_once/include_once is useful.

            Comment

            • Sanders Kaufman

              #7
              Re: Also... Re: PHP includes question

              Nu wrote:
              I have seen code like this:
              if ( file_exists( "$IP/languages/classes/$class.deps.php " ) ) {
              include_once("$ IP/languages/classes/$class.deps.php ");
              }
              It appears not to load the file unless an if statement passes.
              Well, I could be wrong - it would be as easy as RTFM to verify. :)

              But yeah - the file gets loaded no matter what.

              Comment

              • Nu

                #8
                Re: Also... Re: PHP includes question

                "Sanders Kaufman" <bucky@kaufman. netwrote in message
                news:8vhwh.2294 $4H1.1364@newss vr17.news.prodi gy.net...
                Nu wrote:
                "Sanders Kaufman" <bucky@kaufman. netwrote in message
                >
                In the above example - BOTH files will be included no matter what.
                Okay, but both files have include/requires. Will their include/requires
                be
                included, too?
                >
                Yeah - that's why the require_once/include_once is useful.

                What if I put the "require_on ce" in an if statement and put the file to
                require in a variable?


                Comment

                • Curtis

                  #9
                  Re: Also... Re: PHP includes question

                  On Thu, 01 Feb 2007 00:22:27 -0800, Nu <no@spam.comwro te:
                  >
                  "Sanders Kaufman" <bucky@kaufman. netwrote in message
                  news:Klgwh.2288 $4H1.1860@newss vr17.news.prodi gy.net...
                  >Nu wrote:
                  >>
                  Also, does it matter if I put "require_on ce" lower down in the code
                  after
                  some other code my abort it?
                  >>
                  >No - and you may find this weird.
                  >An include/require will be included no matter what.
                  >>
                  >For example:
                  ><? php
                  >if(TRUE){
                  >include "myfile.php ";
                  >} else {
                  >include "yourfile.p hp";
                  >}
                  >?>
                  >>
                  >In the above example - BOTH files will be included no matter what.
                  >
                  >
                  >
                  I have seen code like this:
                  >
                  if ( file_exists( "$IP/languages/classes/$class.deps.php " ) ) {
                  include_once("$ IP/languages/classes/$class.deps.php ");
                  }
                  >
                  >
                  It appears not to load the file unless an if statement passes.
                  >
                  >
                  It can't include a file that doesn't exist, it's not because it's in an if
                  statement, it's what the if statement checks.

                  --
                  Curtis, http://dyersweb.com

                  Comment

                  • Nu

                    #10
                    Re: Also... Re: PHP includes question


                    "Sanders Kaufman" <bucky@kaufman. netwrote in message
                    news:cwhwh.2295 $4H1.1365@newss vr17.news.prodi gy.net...
                    Nu wrote:
                    >
                    I have seen code like this:
                    if ( file_exists( "$IP/languages/classes/$class.deps.php " ) ) {
                    include_once("$ IP/languages/classes/$class.deps.php ");
                    }
                    It appears not to load the file unless an if statement passes.
                    >
                    Well, I could be wrong - it would be as easy as RTFM to verify. :)

                    I can't find anything in the manual on this.


                    Comment

                    • Sanders Kaufman

                      #11
                      Re: Also... Re: PHP includes question

                      Nu wrote:
                      What if I put the "require_on ce" in an if statement and put the file to
                      require in a variable?
                      That's a good start to a question.
                      Wanna finish it?

                      Comment

                      • Sanders Kaufman

                        #12
                        Re: Also... Re: PHP includes question

                        Nu wrote:
                        "Sanders Kaufman" <bucky@kaufman. netwrote in message
                        news:cwhwh.2295 $4H1.1365@newss vr17.news.prodi gy.net...
                        >Nu wrote:
                        >>
                        >>I have seen code like this:
                        >> if ( file_exists( "$IP/languages/classes/$class.deps.php " ) ) {
                        >> include_once("$ IP/languages/classes/$class.deps.php ");
                        >> }
                        >>It appears not to load the file unless an if statement passes.
                        >Well, I could be wrong - it would be as easy as RTFM to verify. :)
                        >
                        I can't find anything in the manual on this.
                        Check the page that discusses "require_on ce" and "include_on ce".
                        It's all there.

                        Comment

                        • Kimmo Laine

                          #13
                          Re: Also... Re: PHP includes question

                          "Sanders Kaufman" <bucky@kaufman. netwrote in message
                          news:Klgwh.2288 $4H1.1860@newss vr17.news.prodi gy.net...
                          Nu wrote:
                          >
                          >Also, does it matter if I put "require_on ce" lower down in the code after
                          >some other code my abort it?
                          >
                          No - and you may find this weird.
                          An include/require will be included no matter what.
                          >
                          For example:
                          <? php
                          if(TRUE){
                          include "myfile.php ";
                          } else {
                          include "yourfile.p hp";
                          }
                          ?>
                          >
                          In the above example - BOTH files will be included no matter what.
                          Okay... suppose you wrote
                          if(FALSE){
                          eval('include(" foo.php");');
                          }

                          Is foo.php included in this case? Can you eval an include statement?

                          --
                          "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
                          http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
                          spam@outolempi. net | rot13(xvzzb@bhg byrzcv.arg)


                          Comment

                          • Sanders Kaufman

                            #14
                            Re: Also... Re: PHP includes question

                            Kimmo Laine wrote:
                            Okay... suppose you wrote
                            if(FALSE){
                            eval('include(" foo.php");');
                            }
                            >
                            Is foo.php included in this case? Can you eval an include statement?
                            Dunno.
                            Try it.

                            Comment

                            • Geoff Berrow

                              #15
                              Re: Also... Re: PHP includes question

                              Message-ID: <Klgwh.2288$4H1 .1860@newssvr17 .news.prodigy.n etfrom
                              Sanders Kaufman contained the following:
                              >No - and you may find this weird.
                              >An include/require will be included no matter what.
                              >
                              >For example:
                              ><? php
                              >if(TRUE){
                              > include "myfile.php ";
                              >} else {
                              > include "yourfile.p hp";
                              >}
                              >?>
                              >
                              >In the above example - BOTH files will be included no matter what.
                              Not quite sure what you are saying here as this clearly is not the case
                              in practice.



                              <a href='includes. php?file=f1'>fi le one</a| <a
                              href='includes. php?file=f2'>fi le two</a><br><br>
                              <?php

                              if(isset($_GET['file'])&& $_GET['file']=="f1"){
                              include("f1.php ");
                              }
                              elseif(isset($_ GET['file'])&& $_GET['file']=="f2"){
                              include("f2.php ");
                              }
                              else{
                              echo "No file included";
                              }

                              ?>

                              --
                              Geoff Berrow (put thecat out to email)
                              It's only Usenet, no one dies.
                              My opinions, not the committee's, mine.
                              Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                              Comment

                              Working...