Welcome Guest, Not a member yet? Register   Sign In
How do I define a global variable after the Codeigniter instantiation?
#1

Hi,

This post recommends putting global variables in
Code:
/application/config/constants.php
however, that too early. I need the global variable to be assigned after the controller instantiation. Is there a way of doing that?

Cheers
Reply
#2

You would need to either place it in the BaseController or create a library for it using static variable.
Or  use Events, see below:

CodeIgniter 4 User Guide - Events
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(08-31-2021, 04:04 AM)InsiteFX Wrote: You would need to either place it in the BaseController or create a library for it using static variable.
Or  use Events, see below:

CodeIgniter 4 User Guide - Events

Thanks, but I'm using CI 3
Reply
#4

Then you can use a hook lookup hooks in the user guide.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB