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

  • SEARCH
  • Home
  • 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 6911747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:59:48+00:00 2026-05-27T08:59:48+00:00

For my current project i decided to create a library for some common functionalities.

  • 0

For my current project i decided to create a library for some common functionalities.

Ex : Login_check,get_current_user etc.

With my little knowledge i created a simple one but unfortunately its not working.

Here my library :

FileName : Pro.php and located in application/libraries

class Pro{

    public function __construct()
    {

       parent::_construct();
        $CI =& get_instance();
       $CI->load->helper('url');
       $CI->load->library('session');
       $CI->load->database();
    }

    function show_hello_world()
    {
        $text = "Hello World";
        return $text;
    }
}

?> 

And i tried to load it on my controller :

<?php
class Admin extends CI_Controller
{
    function __construct()
    {     
        parent::__construct();
        $this->load->database();
        $this->load->library(array('session'));
        $this->load->library("Pro");
    }
    function index()
    {
        echo($this->Pro->show_hello_world());
    }
}

?>

I cant see any erros there…but i am getting a blank page.

Whats wrong with me ??

Thank you .

Edit : I got this error :

Call to a member function show_hello_world() on a non-object in C:\wamp\www\Project\application\controllers\admin.php on line 13
  • 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-05-27T08:59:49+00:00Added an answer on May 27, 2026 at 8:59 am

    One thing I notice: remove the parent::__construct() from your library constructor, because it’s not extending anything so has no parent to call.

    Also, enable error reporting by setting the environment to “development” in index.php, and you might also want to raise the logging threshold to 4 in config/config.php so you log errors.

    Try this simple test-case:

    file Pro.php in application/libraries:

    class Pro {
    
      function show_hello_world()
      {
        return 'Hello World';
      }
    }
    

    Controller admin.php in application/controllers

    class Admin extends CI_Controller
    {
        function index()
        {
            $this->load->library('pro');
            echo $this->pro->show_hello_world();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In order to separate concerns, on my current project, I've decided to completely separate
My current project requires extensive use of bit fields. I found a simple, functional
I've come across a place in my current project where I have created several
In the current project we have decided to use dto's to transfer data between
So i'm working with CakePHP v1.2.5. On my current project, I decided to start
I want to use some good coding standards for the current project. The overall
For my project i need a editable text ,so i decided to use some
It seems the previous developers of the current project I'm working with decided to
I decided to get back to Cocoa/Objective-C programming recently and my current project calls
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python)

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.