Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8706749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:41:29+00:00 2026-06-13T03:41:29+00:00

Basically I have a helper file with several function. I auto load the helper

  • 0

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;
        }

    }   

}   
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:41:31+00:00Added an answer on June 13, 2026 at 3:41 am

    Below line has problem

    public $member_session = is_member();
    

    You can’t initialize class variable with function call. it should have some static value not dynamic

    Because of this, you also getting parse error on line 7

    EDIT

    class Udetails{
    
    public $username = $member_session['username'];
    public $current_uID = $member_session['id'];
    public $member_status = $member_session['status'];
    
    public function get_data(){
        $CI =& get_instance();// referencing as described in their website
        $CI->load->helper('mylogin_helper');// loading the helper
    
        $member_session = is_member(); // using the function 
    
        $this->username = $member_session['username'];
        $this->current_uID = $member_session['id'];
        $this->member_status = $member_session['status'];
    
    }
    
    
    }
    

    In Controller,

    $this->load->library('udetails');
    
    echo "<pre>";
     print_r ($this->udetails->get_data());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So basically I have a helper - function records() { $ci = get_instance(); $ci->db->order_by(date,
I have a helper function, which basically calls CompareTo on two objects, but does
I basically have a program that filters records from one excel file to another
I have a TextArea html helper method I'm calling in a foreach loop. Basically,
I am trying to create a helper function to read a file and mock
I have a Preference class (module) that's used across several different apps. Basically it's
Basically my problem is this: I have a CSV excel file with info on
This is contrived, but its basically what I'm doing. I have an a @helper
I am new to ZF.i have made a function that basically make a Form
I basically have three tables, posts, images and postimages (this simply contains the ids

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.