Difference Between require_once And require

Really caught me by surprise this morning. The poor intern had to manually click the item one by one.

foobar.php
<?php
foreach ( range(0, 4) as $no )
{
require_once 'a.php';
require 'b.php';
}

a.php
<?php echo "a:$no\n"; ?>

b.php
<?php echo "a:$no\n"; ?>

$ php -f foobar.php
a:0 <----- notice that a.php only include ONCE
b:0
b:1
b:2
b:3
b:4

No comments:

Post a Comment