Stratergy pattern with CodeIgniter - Abstract classes |
[eluser]1cookie[/eluser]
hi Ive been reading a book about design patterns (strategy) with PHP. I've got it working in native PHP like so: Code: <?php This prints: Quote: lesson charge: 20 - charge type: Houly Rate. to the browser - correct output! The trouble begins when I try to acheive the same thing in CI with: Code: //controller: Code: //view: The above prints: Quote:A PHP Error was encountered to the browser. A uml diagram can be seen here So in my codeigniter version Code: $lesson->cost()
[eluser]PhilTem[/eluser]
You were overwriting your $data['lessons'] array. I think within your controller it should be Code: $data['lessons'] = array(); yet the rest of the code looks good. Try it with these little changes and tell me if it worked. Using "normal" PHP coding in CI is possible and CI doesn't restrict you to use it. So your code is totally right and should work, if you changed those two lines from above ![]()
[eluser]1cookie[/eluser]
[quote author="PhilTem" date="1331163434"]You were overwriting your $data['lessons'] array. yet the rest of the code looks good. Try it with these little changes and tell me if it worked. Using "normal" PHP coding in CI is possible and CI doesn't restrict you to use it. So your code is totally right and should work, if you changed those two lines from above ![]() Thanks for the help Phil. At this point I think I should show you the rest of the code as we're getting more errors: Quote:A PHP Error was encountered Code: // Lesson.php Code: // FixedCostStrategy.php Code: // TimedCostStrategy.php Code: // CostStrategy.php Code: // Seminar.php Code: <?php |
Welcome Guest, Not a member yet? Register Sign In |