Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create global variables in CakePHP?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 4.61k
    Comment on it

    The majority of the developers, develop skepticism in which, what's the correct place/Page in which they should declare the constant variable in cakephp.

    Previous going to variable declaration, we must consider that any of us will work over a MVC platform and also we should not break the rules of MVC.

    There are many place in which we are able to establish the particular constant variables in cakephp, these include practices

    METHOD-1
    Get a file referred to as core.php inside app/config/ folder involving cakephp setup listing.
    Presently there you will need to open the particular core.php.
    app/config/core.php
    For you to declare a constant global variable in cakephp, core.php only create following syntax.

    1 Configure:: write('variableName', 'value');

    In order to constant global variable your Controller/Model/View, that is declared in core.php. Only create the particular underneath syntax in Controller or Product or Check out, you may competent to admittance in which varying.

    Configure:: read(variableName);

    METHOD-2

    Much like cakephp rule you can declare all your constant variable as well as global variables in bootstrap.php file.
    With cakephp setup, you'll discover 2 bootstrap.php reports.
    1 report is cakephps core bootstrap. php
    2nd report is Application unique bootstrap.php.
    For Application unique bootstrap report goto following course and also open bootstrap.php report app/config/bootstrap.php

    Pursuing the syntax in order to constant variable in bootstrap.php involving cakephp
    $variableName = 'Nirdesh';

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: