Welcome Guest, Not a member yet? Register   Sign In
Correct way to use homemade functions
#3

[eluser]eedfwChris[/eluser]
The variable $data is still in it's own function scope...
You would do this:
Code:
class Test extends Controller {
    function Test()
    {
        parent::Controller();
        $this->load->helper('my'); // according to the User Guide, I don't have to tell CI where to find this file, or show the "_helper.php" part.
    }

    function index()
    {
        $data['testing'] = "Testing this out.";
        $data['message'] = hello();
        $this->load->view('test', $data);
    }
}

application/helpers/my_helper.php
Code:
function hello() {
        return 'Hi there!';
    }


Messages In This Thread
Correct way to use homemade functions - by El Forum - 08-14-2007, 01:27 PM
Correct way to use homemade functions - by El Forum - 08-14-2007, 01:34 PM
Correct way to use homemade functions - by El Forum - 08-14-2007, 01:36 PM
Correct way to use homemade functions - by El Forum - 08-14-2007, 01:37 PM
Correct way to use homemade functions - by El Forum - 08-14-2007, 01:42 PM
Correct way to use homemade functions - by El Forum - 08-14-2007, 01:43 PM
Correct way to use homemade functions - by El Forum - 08-14-2007, 01:45 PM
Correct way to use homemade functions - by El Forum - 08-14-2007, 02:17 PM
Correct way to use homemade functions - by El Forum - 08-14-2007, 08:58 PM
Correct way to use homemade functions - by El Forum - 08-15-2007, 01:08 PM
Correct way to use homemade functions - by El Forum - 08-15-2007, 01:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB