Re: The require and include

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Include is faster than require, not the other way around. See for example
[1] (the text is french, but you'll get the performance difference.), it
shows include is about 38% faster on 1000 includes.

I also don't think require includes files before the script is run, because
PHP is a dynamic language, and you might do things like include
$somevar.".php"; or require $somevar.".php"; which can only be done when
PHP knows what somevar will be. Note that I do absolutly recommend NOT to
use variables for including, as it leads to possible security issues,
especially when the var is related to user input.

As of how to use it, I'd say read the PHP manual [2], but it is as simple
as replacing the word include with require.

- Matijn

[1] http://dev.petitchevalroux.net/php/benchmark-require-include-php.34.html
[2] http://www.php.net/require


On Sat, Nov 10, 2012 at 5:38 PM, andrej arshinow <arshandrej@xxxxxxxxx>wrote:

> I knew that before the function require a faster because All files are
> included before run the script. Now is this? And how to use it?
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux