Welcome Guest, Not a member yet? Register   Sign In
Loading library from name


I have trouble to use a library that I load depending on a variable data.

$mylibrary = 'Custom_Lib';
$mymethod = 'Method1';
//those two are retreived from a database.

//After I use the method:


//I have an error that I'm calling a method on a non object...

I've tried also
class_alias(strtolower($mylibrary), 'useclass');

//same problem...

Any one have an advise to call a special library/method from dynamicly ?

Thanks for your help,


Does it work if you access it directly instead of using a variable?

One thing that may cause that is when you use $this->library_name, "library_name" I believe should be lower case. You're using $mylibrary, where the variables value isn't lower case.

So it just might need something like:
$mylibrary = strtolower($mylibrary); //force to lower case before accessing

Did you try it using the actual names instead of variables to test?

Thanks CroNIX,

Your solution was the right one !

Always use lowercase for library call...

Theme © iAndrew 2016 - Forum software by © MyBB