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:
"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://codeigniter.com/user_guide/general/creating_libraries.html
and try referencing and loading but that also through an error:
"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:
class Udetails{
$CI =& get_instance();// referencing as described in their website
$CI->load->helper('mylogin_helper');// loading the helper
public $member_session = is_member(); // using the function
public $username = $member_session['username'];
public $current_uID = $member_session['id'];
public $member_status = $member_session['status'];
}
Here is the function within the helper:
if ( ! function_exists('is_member'))
{
function is_member(){
$CI =& get_instance();
$is_logged_in = $CI->session->userdata('is_logged_in');
$username = $CI->session->userdata('username');
$capabilities = $CI->session->userdata('capabilities');
$user_id = $CI->session->userdata('id');
switch ($capabilities){
case 'registered':
$level = 1;
break;
case 'confirmed':
$level = 2;
break;
case 'charity_admin':
$level = 3;
break;
case 'admin':
$level = 4;
break;
case 'super_admin':
$level = 5;
break;
default:
$level = 0;
}
$userdetails = array();
if(isset($is_logged_in) && $is_logged_in == true){
if($level > 1){
$userdetails['username'] = $username;
$userdetails['status'] = TRUE;
$userdetails['id'] = $user_id;
return $userdetails;
}
}
}
}
Below line has problem
You can’t
initialize class variable with function call. it should have some static value not dynamicBecause of this, you also getting parse error on line 7
EDIT
In Controller,