hi every body .
i want to know "difference between require, require_once and register " for Security code of my system & Speed System .
my result search :
require 'file1': It will include the code of the file1. In case file1 does not exist it will generate a fatal error and script will stop executing further.
require_once 'file1' : It works the same way. The only difference between require and require_once is that require_once does not include and evaluates file again if it has been included earlier
So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example.
functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error
Difference between require() and require_once(): :
require() ==> includes and evaluates a specific file,
while require_once() ===> does that only if it has not been included before (on the same page).
AND I WILL BE HAPPY if help me know more details AND difference between require_once and elgg_load_library ???
thanks :)
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Juho Jaakkola@juho.jaakkola

Juho Jaakkola - 1 like
- Juho Jaakkola@juho.jaakkola

Juho Jaakkola - 1 like
- fonly@fateme

fonly - 1 like
You must log in to post replies.elgg_load_library() can be used to include a *named* file that's been registered earlier using elgg_register_library(). That way you don't have to enter the file location but just the name.
require_once() works the same but instead of a name you pass int the location of the file.
(Also look into using classes instead of function libraries. Elgg has an autoloader for those, so you don't have to either require_once or elgg_load_library: http://learn.elgg.org/en/1.12/guides/plugins/plugin-skeleton.html?highlight=autoload#classes).
In the end the it doesn't really make any difference for either speed or security whether you use elgg_load_library() or require_once(). Just make sure that you use lazy loading. Don't include any files or libraries needlessly.
thanks a lot Mr jaakkola :)