I am creating a new library to codeignighter, seem i cannot use/load helper i've created |
[eluser]netameta1[/eluser]
basically i have a helper file with several function. I auto load the helper in the config file so theoretically reloading it is not required. However when i try to use the function that i created(from this helper) within a new library that i am working on it will through this error: Code: "Parse error: syntax error, unexpected '(', expecting ',' or ';' in /home/techwork/public_html/giverhub/application/libraries/Udetails.php on line 7" Whenever i use that function anywhere else(module,controller,views) it works fine. I then read and thought maybe i should try loading the helper after following instructions at: http://ellislab.com/codeigniter/user-gui...aries.html and try referencing and loading but that also through an error: Code: "Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/techwork/public_html/giverhub/application/libraries/Udetails.php on line 5" Here is the library: Code: class Udetails{ Here is the function within the helper: Code: if ( ! function_exists('is_member')) Thanks in advanced.
[eluser]PhilTem[/eluser]
You need to wrap this code Code: $CI =& get_instance();// referencing as described in their website into the __construct()-method to make it work, but before that you should define the variables as class attributes, so you don't get referencing errors. That's because you can't use anything but Code: private $var = array(), NULL, FALSE, ''; as initial value for a class attribute. And you can't put $CI =& get_instance() inbetween the class tags without wrapping a method around it.
[eluser]netameta1[/eluser]
i changed it to this: Code: class Udetails{ is this the correct way ? Also how will i get to those variables in other methods afterward ? Thanks again
|
Welcome Guest, Not a member yet? Register Sign In |