PHP Scripting in Views |
[eluser]Tim Reynolds[/eluser]
Hi, I have programmed in procedural php before but now decided to get into a framework and CodeIgniter looked like a great choice. Am getting to grips with it well just have one question. While following a great screen cast by Elliot Haughin he used the following Syntax to output an array in a view, Code: <?php if (isset($navigation) && !empty($navigation));?> Now i am use to JSTL in Java and this seems the same principle but I could not get it to work. Instead i used echo like so, Code: <?php Using echo worked fine but why did the other method not work correctly? Is it to do with server config or am i just doing it wrong? I am running MAMP with default settings and the latest release of CI. Am sure there is a simple answer. Thanks for your help in advanced. Tim
[eluser]Armchair Samurai[/eluser]
AFAIK, the syntax posted is wrong - rather than use a semi-colon to open your conditional, you should use a colon. Code: <?php if (isset($navigation) && !empty($navigation)):?> // colon, not semi-colon Code: <?php if (isset($navigation) && !empty($navigation)){?>
[eluser]pistolPete[/eluser]
This is also covered by the user guide: Alternate PHP Syntax for View Files.
[eluser]Tim Reynolds[/eluser]
Thank you. I like the look of the alternate PHP Syntax seems much easier. |
Welcome Guest, Not a member yet? Register Sign In |