Public response to A Kaufman

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

    Public response to A Kaufman

    Dear A Kaufman, I can't IMAGINE what you mean by this post in one previous
    thread.

    =============== =============== =============== ====
    "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."
    =============== =============== =============== ====

    This is NOT OF COURSE the case!



    Here I have in same folder files myfile.php and yourfile.php, other one
    echoing
    This text comes from file myfile.php
    and other one echoing
    This text comes from file yourfile.php

    but OF COURSE test.php prints only "This text comes from file myfile.php"


  • Captain Paralytic

    #2
    Re: Public response to P Pulkkinen

    On 1 Feb, 11:14, "P Pulkkinen"
    <perttu.POISTAT AMA.pulkki...@P OISTATAMA.elisa net.fiwrote:
    Dear A Kaufman, I can't IMAGINE what you mean by this post in one previous
    thread.
    >
    =============== =============== =============== ====
    "An include/require will be included no matter what.
    >
    For example:
    <?php
    if(TRUE){
    include "myfile.php ";} else {
    >
    include "yourfile.php"; }
    >
    ?>
    >
    In the above example - BOTH files will be included no matter what."
    =============== =============== =============== ====
    >
    This is NOT OF COURSE the case!
    >

    >
    Here I have in same folder files myfile.php and yourfile.php, other one
    echoing
    This text comes from file myfile.php
    and other one echoing
    This text comes from file yourfile.php
    >
    but OF COURSE test.php prints only "This text comes from file myfile.php"
    He did not say that the contents of both files would be executed, he
    said that both files would be included. The if/then/else statement
    will ensure that the contents of yourfile.php do not get executed,
    however they WILL be included.

    Comment

    • Sanders Kaufman

      #3
      Re: Public response to A Kaufman

      P Pulkkinen wrote:
      Dear A Kaufman, I can't IMAGINE what you mean by this post in one previous
      thread.
      My bad. I'm still thinking the old way.
      I really wish I'd known they'd changed it - because this would
      have come in handy a LOT over the last little while.

      Here's the section from the PHP docs:

      Note: Prior to PHP 4.0.2, the following applies: require()
      will always attempt to read the target file, even if the line
      it's on never executes. The conditional statement won't affect
      require().

      Comment

      • Kimmo Laine

        #4
        Re: Public response to P Pulkkinen

        "Captain Paralytic" <paul_lautman@y ahoo.comwrote in message
        news:1170328792 .349222.6920@l5 3g2000cwa.googl egroups.com...
        On 1 Feb, 11:14, "P Pulkkinen"
        <perttu.POISTAT AMA.pulkki...@P OISTATAMA.elisa net.fiwrote:
        >Dear A Kaufman, I can't IMAGINE what you mean by this post in one
        >previous
        >thread.
        >>
        >============== =============== =============== =====
        >"An include/require will be included no matter what.
        >>
        >For example:
        ><?php
        >if(TRUE){
        >include "myfile.php ";} else {
        >>
        >include "yourfile.php"; }
        >>
        >?>
        >>
        >In the above example - BOTH files will be included no matter what."
        >============== =============== =============== =====
        >>
        >This is NOT OF COURSE the case!
        >>
        >http://perttu.finote.com/muuta/test.php
        >>
        >Here I have in same folder files myfile.php and yourfile.php, other one
        >echoing
        >This text comes from file myfile.php
        >and other one echoing
        >This text comes from file yourfile.php
        >>
        >but OF COURSE test.php prints only "This text comes from file
        >myfile.php"
        >
        He did not say that the contents of both files would be executed, he
        said that both files would be included. The if/then/else statement
        will ensure that the contents of yourfile.php do not get executed,
        however they WILL be included.
        A proper way to test it might be including a HUGE (like Donald Trump Huge) a
        file and see if there's a performance peak... like this:

        <?php

        $started = time();

        if(FALSE){
        require('my_hug e_1Gb_bogus_fil e.php');
        }
        echo 'elapsed = '.(time()-$started);

        ?>

        I'm thinking if elapsed time jumps thru the roof, then the file was accessed
        and read into memory, but not executed thou. my_huge_1Gb_bog us_file.php
        could just be <?php /* LOL OMG THIS IS A TEST LOL OMG THIS IS A TEST LOL OMG
        THIS IS A TEST .... */ ?repeated a zillion times so that the file size
        would actually become gigantic.

        Another thing is that if you use require and a non-existing file, php
        doesn't throw an error if the require statement is unreachable, like behind
        if(FALSE), only when the file really is included in the code.

        --
        "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

        • irezvin

          #5
          Re: Public response to P Pulkkinen


          Another thing is that if you use require and a non-existing file, php
          doesn't throw an error if the require statement is unreachable, like behind
          if(FALSE), only when the file really is included in the code.
          Sorry, people, to disturb you, but if php attempts to scan every
          include()'d or require()'d file, how it deals with such construct?

          if (false) {
          $fileName = 'someFile.php';
          include($fileNa me);
          }

          Even if include statement is processed, the $fileName var won't be
          initialized before that point! I used such construct a lot, and
          haven't get any errors or messages! Or even slowdonws! And you can
          include/require you files in a loop, continiuosly changing the
          filename or many other ways... so I think that PHP does not behave
          that way, it does not process includes or requires that are not in the
          execution thread.

          Comment

          Working...