Hello All,
In this blog we will discuss creation of global variables in CakePhp.
Sometimes there is a need to access a variable everytime in the application, so instead of declaring it again and again we can declare the variable globally so that it can be used anywhere in the application.
So there comes the concept of the variables so called global variables.
Global variables are the variables that can be accessible anywhere in the application.
In CakePhp we can declare global variable in your app/config/core.php
Example-
Configure::write('variable Name','Variable Value');//How to declare the global variable in core.php
Configure::write('BASE_URL','https://'.$_SERVER['HTTP_HOST']);//Example showing how to use the variable
So as in the above example you can excess the BASE_URL variable anywhere in your cakephp application.
0 Comment(s)