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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:32:34+00:00 2026-06-01T05:32:34+00:00

I am using Codeignitor for programming and coming from c#. its look like a

  • 0

I am using Codeignitor for programming and coming from c#.
its look like a newbie question ,but i want to do something like this.

I have some functions that which return some values :

Example :

function Create_db()
{

//do something

      if (PassWordError) //some errors here it is password incorrect
       {
         return "PASS_ERROR";
       }

}

and in some places i am using like this

$result = Create_db(); //assume that there are some problems and returned "PASS_ERROR"

so that the $result is string now,

is there anything like ENUMS in php ? or something like that ?

so that i can do something like this :

if (passWordError)
{
  return $error->PasswordError();
}

i assume that i can have some others types too

like

Maximum_name_error,authenticationFailedError etc

Thank you.

  • 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-01T05:32:36+00:00Added an answer on June 1, 2026 at 5:32 am

    A typical approach to doing this in PHP would be to use class constants:

    class Something {
        const ERR_HI = 'hi';
        const ERR_FOOBAR = 'foobar';
    }
    
    
    //to use:
    return Something::ERR_FOOBAR;
    

    Although I would consider using exceptions instead.

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

Sidebar

Related Questions

I'm using CodeIgniter (because it's awesome) and I have something like: <?php echo anchor(/,
I have authentication up and running in CodeIgnitor using Ion Auth, seems to be
This question straddles both programming and server issues, not sure it is 100% for
I am using CodeIgniter and on an edit form its pulling in data from
Very new to web programming still and I don't really have a specific question
I'm using codeigniter for this project. I have a search form and search form
For my current project in codeignitor I needed to make user profile like this
I am using Codeigniter (for the first time). I want to have the URL
I am using Plupload with codeignitor. My problem is i cant create new folder
I am using Codeigniter framework and I have a form with input fields. When

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.