Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Dumb question =(


Message #1 by "Bill" <bige88fan@c...> on Sat, 21 Dec 2002 04:46:04

> >If I had a file to include into another file (Eg. functions.php), and I
> >put the function set_time_limit(); inside of the functions.php file, would
> >the file it is being included on, take on that function, and set the time
> >limit on the script functions.php is included on?
> >
>
> Yes, that sounds right.  You will still need to call the function to
> make it do anything.

The easiest way to think about include() (and it's related functions
include_once, require, and require_once) is that this line:


include('file.php');

is replaced by PHP with this:

?>(file.php contents)<?php



There's no new scope involved or anything; the contents of the file are merely
parsed in-place.


For example:

<?php  // some_file.php

echo $i . "\n";

?>



Simple, right?  Let's continue:


<?php  // main.php

for($i = 0; $i < 5; ++$i)
{
  include('some_file.php');
}

?>



This will print

0
1
2
3
4


Hope this clears things up!

nik




  Return to Index