Sunday, March 29, 2009

require_once and include_once in php

The include_once parameter is almost same as include and the require_once parameter is almost same as require. Both of require and include is described with example in http://arjudba.blogspot.com/2009/03/require-and-include-parameter-in-php.html. The only difference from include and require is that with require_once/include_once if the file is already included, it will not include again.

For example, if within your script you use below code then behavior will depend based on php version and OS type.

<?php
include_once 'test.php';
include_once 'Test.php';
?>

As of php 4.0 once test.php is included and then again Test.php is included regardless of OS. For case insensitive OS both test.php and Test.php point just one file but they are included twice. This behavior is changed in php 5.0. From php 5.0, on case insensitivity OS for example on windows machine test.php is included only once. But on unix file system they are included in each test.php and Test.php as they represent two different files.

Related Documents
http://arjudba.blogspot.com/2009/03/class-inheritance-example-in-php.html
http://arjudba.blogspot.com/2009/03/class-concepts-and-usage-syntax-in-php.html
http://arjudba.blogspot.com/2009/03/require-and-include-parameter-in-php.html

No comments:

Post a Comment