Check for a variable in sight using a code igniter

At Codeigniter, I want to know how best to use the same views with different functions in the controller.

For example, in an index function, I have $ locals ['somevar'] = "some thing";

    $this->load->view('welcome_message', $locals);

In my opinion, I have something like this:

<?php if($somevar):?>       
    <?=$somevar?>
<?php endif;?>

Trying to make a Ruby on Rails object where I can check for the presence of a Flash / notification before showing it.

However, in the test function (i.e., not passing the variable to the view this time)

   $this->load->view('welcome_message')

The view seems to have a value of $ somevar and errors.

: () - , ? , , , , , . .

+3
1
<?php if (isset($somevar)): ?>       
    <?php echo $somevar; ?>
<?php endif; ?>
+7

Source: https://habr.com/ru/post/1770037/


All Articles