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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:39:37+00:00 2026-05-23T11:39:37+00:00

I use codeigniter, one of the main issues i have with the views is

  • 0

I use codeigniter, one of the main issues i have with the views is undefined variables that may or may not exist.

I know that it’s easy to get rid of the notices when using something like:

<?=html($this->input->post('name'))?>

By adding if(isset(..){ html($this->input->post('name')); }

But it’s very annoying and it makes the code look ugly, I also don’t want to disable notice reporting.

Is there any advice about that?

  • 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-23T11:39:38+00:00Added an answer on May 23, 2026 at 11:39 am

    The “best” way? I still say it’s isset. It’s nice to be explicit, and it would help me, as someone maintaining your code later, to realize that you are okay with that variable not existing and that it wasn’t just a mistake. Unless the isset check were there, I’d assume you just didn’t realize it was possible for it not to be set, and would wonder what you actually meant to do.

    Additionally, I’d assert that one of the main reasons it looks ugly is because all the code is being crammed into one line. There are two things you’re trying to do: check if it’s set, and print it if so. Maybe spacing them out would look nicer, even if it’s a bit more verbose:

    <?php if( isset($this->input->post('name')) ): ?>
        <?= $this->input->post('name') ?>
    <?php endif ?>
    

    This also makes the snippet easier to manage later, in case you later decide to, say, wrap the output in an HTML tag, or add an else case.

    Plus, since, according to the question, we can’t mess with the error reporting settings, checking for the variable’s existence is the only option. Sorry. Either you check if it’s set, or disable the error messages saying it’s not. No middle road.

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

Sidebar

Related Questions

I have a project that I am developing built off CodeIgniter. The main part
How to use two views in one controller in codeigniter function index() { $data['title']
I have 54 sites that have different URLS but use the exact same codeigniter
How can i create a main page with codeigniter? That page should contain a
and sorry if that question is stupid I'm trying to use javascript with codeigniter
I use CodeIgniter and i love it, but i don't know whether it's really
I'm just learning codeigniter, and I seem to have run into something that is
I currently use CodeIgniter as my framework of choice when using PHP. One of
In one of my controllers, i use codeigniter's form validation helper. One of my
I have a codeigniter form that contains two checkboxes: <input type=checkbox checked=checked id=box1 name=box1

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.