Actually JLoader::register('TestHelper','/path/to/test.php');
dosen't load file, it just registers it to be able to autoload file if class is instantiated.
Do require it instantly, you want to use:
JLoader::import('TestHelper','/path/to/test.php');
Note: for this your file name should be TestHelper.php
.
which will
include_once
the file if it exists (with require_once
you would get PHP error, if it dosen't exist. Now you would get pretty Joomla! error).
Will remember that this file is already loaded and wont include_once
it again. This results in minor performance gain.
which won't
JLoader::register()
your class, so you can't use JLoader::load()
later.
All in all:
- Minor performance gain.
- It's good practice to follow coding style of framework (though Joomla! dosen't do it everywhere itself).
- You can use dot notation for class name (not applicable for
*Helper
classes.).
Dot notation example
jimport('sub.path.classname','/path/to/')
would include_once
file in /path/to/sub/path/classname.php
NOTE
JLoader::import('TestHelper','/path/to/test.php')
has shorthand
jimport('TestHelper','/path/to/test.php')