Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • compact() or set() in cakephp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 4.31k
    Comment on it

    set() is the way to set values in your controller and get those values in your view file.

    Syntax of set is-> $this->set('variable','value')
    
    In cake-php controller you can set the values as - set('variable1','value1'); $this->set('variable2','value2'); $this->set('variable3','value3'); ?>

    To set multiple value we use 'compact()' function -

    Syntax of compact - $this->set(compact('varible1','variable2','variable2',......));
    

    Ex - $data = 3; $dataone = 4; $datatwo = 5;

    So set above in your controller's function like - $this->set(compact('data','dataone','datatwo'));

    And in view file get as -

 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: