PHP includes question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Toby A Inkster

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

    Geoff Berrow wrote:
    <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";
    }
    >
    ?>
    This doesn't really disprove Sanders' point: both files may have been
    included, but only one output to the browser -- the other one may have
    simply been parsed and ready.

    That said, I believe the behaviour Sanders describes was changed with
    PHP 4. include()ed and require()ed files are now only loaded on demand.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Geek of ~ HTML/CSS/Javascript/SQL/Perl/PHP/Python*/Apache/Linux

    * = I'm getting there!

    Comment

    • Geoff Berrow

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

      Message-ID: <vodb94-q77.ln1@ophelia .g5n.co.ukfrom Toby A Inkster
      contained the following:
      >This doesn't really disprove Sanders' point: both files may have been
      >included, but only one output to the browser -- the other one may have
      >simply been parsed and ready.
      I'd doubt parsed because errors don't show until the file is used. As
      far as the programmer is concerned it is as if it is never read.
      --
      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

      • Jerry Stuckle

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

        Sanders Kaufman wrote:
        Nu wrote:
        >"Sanders Kaufman" <bucky@kaufman. netwrote in message
        >news:cwhwh.229 5$4H1.1365@news svr17.news.prod igy.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.
        Yep.

        "The include_once() statement includes and evaluates the specified file
        during the execution of the script."

        It's an execution time statement, not a compile time statement.
        Therefore it will only include the file if this statement is executed.

        For instance:

        if (false)
        include_once('m yfile.php');

        will never include the file.

        require_once() has a similar statement.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        Working...