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 7822417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:55:10+00:00 2026-06-02T07:55:10+00:00

I have started playing with CodeIgniter now. And I use their user guide and

  • 0

I have started playing with CodeIgniter now.
And I use their user guide and other third-party tutorials available for learning. I’m a bit stuck at the naming of private functions. Based on the user guide, I have to prefix a _ in the name of private functions. But in this tutorial, check the Add Logout section. In it, there is a private function: private function check_isvalidated(). Here, it is not prefixed with the character _.

So that’s also an accepted naming convention ?
At the same time, there is another one called _output(): Processing Output.
It’s a public function with the naming convention of a private function !

It’s a bit of confusing when I try to learn in a systematic manner.

  • 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-02T07:55:12+00:00Added an answer on June 2, 2026 at 7:55 am

    The _ prefix is a convention for functions defined in the CONTROLLER.

    The user guide says:

    In some cases you may want certain functions hidden from public access. To make a function private, simply add an underscore as the name prefix and it will not be served via a URL request.

    http://www.codeigniter.com/user_guide/general/controllers.html#private-methods

    Adding an _ is CodeIgniter’s own way of declaring functions in the controller (only in the controller) that cannot be called directly by the user:

    • Controller functions are mapped to parts of the URL (controller/function)
    • there are functions in the controller which should NOT be mapped to the URL

      - they are declared as `private` (available since PHP5)
      OR
      - their names start with `_` (works also for PHP4)
      

    Regarding _output function, it is public, but it cannot be called directly since it contains _.

    Why is public?

    The function is called by the system, so it needs to be accessible from outside the class, it is not a private function. But, it contains _ to make sure it is not called via the URL.

    To sum up, if you have functions in your controller which you don’t want to be called directly via the url, add _ prefix OR use the private access operator. Either one of them is good enough.

    FYI, other frameworks like Yii or Zend framework, use the action prefix for all controller functions which CAN be called via the URL (are mapped).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started playing with Haskell and I use Vim. I have autoindent on in
I have just started playing with TeamCity and its great. Now I got it
I have started working on sharepoint . Other than playing around with the development
I have just started playing around with Log4Net... I now want to send an
I have started playing around with Apache camel recently. So being the experimental type
i have just started playing aorund with asp.net mvc and i want to view
I've started playing around with transitions and have come up against quite a big
I have a basic GWT Maven project going. I added SmartGWT and started playing
I have started playing with Maven2 and I'm attempting to port one of my
I have just started playing with Microsoft's 08/2010 WPF Ribbon release. The basics appear

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.