php - CodeIgniter controller isn't passing information to the model -


I am following the examples of an example. I'm not sure what the problem is, when I see PHP from within the body, the controller is crossing the title in the scene. But when I add normal Math problems back to the body, it seems that the controller is not presenting this information in the model. Am I doing wrong here?

Model math.php

  & lt ;? Php class Math CImodel {public function add ($ var1, $ Var2) {return $ var1 + $ var2; } Decrease public function ($ var1, $ var2) {return $ var2 - $ var1; }}   

Controller site.php

   $ This- & gt; Home (); } Public Function Home () {$ data ['title'] = 'Welcome!'; $ Data ['var1'] = 2; $ Data ['var2'] = 5; $ This- & gt; Load-> Model ('math'); $ Data ['addTotal'] = $ this- & gt; Math-> Add ($ data ['var1'], $ data ['var2']); $ Data ['subcottle'] = $ this- & gt; Math-> Decrease ($ data ['var1'], $ data ['var2']); $ This- & gt; Load-> View ('home', $ data); }}   

See home.php

     

Here I got the output ...

Hello World < / P>

Add

2 + 5 = 7

subtract

5 - 2 = 3

You forgot < Strong> concat the "="

  & lt; H3 & gt; Add & lt; / H3 & gt; & Lt; P & gt; & Lt ;? Php echo $ var1 "+" $ Var2 "=" $ copy; ? & Gt; & Lt; / P & gt; & Lt; H3 & gt; Decrease & lt; / H3 & gt; & Lt; P & gt; & Lt ;? Php echo $ var2 "-" $ Var1 "=" $ total; ? & Gt; & Lt; / P & gt;   

should be ...

  & lt; H3 & gt; Add & lt; / H3 & gt; & Lt; P & gt; & Lt ;? Php echo $ var1 "+" $ Var2 "=" $ AddTotal; ? & Gt; & Lt; / P & gt; & Lt; H3 & gt; Decrease & lt; / H3 & gt; & Lt; P & gt; & Lt ;? Php echo $ var2 "-" $ Var1 "=" $ Sub-total; ? & Gt; & Lt; / P & gt;    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -