Trying to improve my code’s agility and loading time, I thought of doing this,
so that the functions would be required only if the class was instantiated.
class User
{
public function __construct()
{
require('all_user_fns.php');
}
}
Inside all_user_fns.php will reside all User class’s functions.
Is that feasible (maybe in another way)? Does it have any advantages when it comes to speed?
To be honest this will be slower (you’re having to do an additional include after all) although meaninglessly so. As such, if speed is really an issue look at one of the opcode caches such as the Alternative PHP Cache (APC)
Somewhat more concerning, it’s going to make maintaining the code painful and will quite possibly cause issues when attempting to use visibility keywords such as private/protected/public depending on what IDE you’re using.