CodeIgniter Forums
End function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: End function (/showthread.php?tid=26506)



End function - El Forum - 01-15-2010

[eluser]jav99[/eluser]
Hey there, am wondering: is it possible to use if(end) using the code igniter way to write php?

am interested that instead of writing this:

Code:
<?php if (end($item) == $item_row)
  {    echo ‘last’;
  }?>
<? else: ?><? endif;?>

i could use the code igniter way of doing things like this

Code:
<?php if (end($item) == $item_row):?>

< p > last </ p >
&lt;? else: ?&gt;&lt;? endif;?&gt;

is this possible?


End function - El Forum - 01-15-2010

[eluser]cahva[/eluser]
This is not CI specific and is supported natively in PHP, so sure you can use it.


End function - El Forum - 01-15-2010

[eluser]jav99[/eluser]
[quote author="cahva" date="1263596444"]This is not CI specific and is supported natively in PHP, so sure you can use it.[/quote]

thanks for ur reply, what i wanted to know is that if there was a CI equivalent, since the html code is cleaner using the CI way using simple CI if statements.


End function - El Forum - 01-15-2010

[eluser]cahva[/eluser]
Sorry, but I dont understand. CI is PHP and you can build the html code the same way. You can get out of PHP anytime with ?&gt; and insert html between and then start it again later. Is this what you were after?


End function - El Forum - 01-15-2010

[eluser]jav99[/eluser]
[quote author="cahva" date="1263597856"]Sorry, but I dont understand. CI is PHP and you can build the html code the same way. You can get out of PHP anytime with ?&gt; and insert html between and then start it again later. Is this what you were after?[/quote]

using if statements in CI u get a very elegant coding layout

Code:
&lt;? if ---?&gt;

html code goes here, plus some more php bits

&lt;? else:?&gt;

&lt;? end if;?&gt;

very elegant and easy to read and understand.


End function - El Forum - 01-16-2010

[eluser]cahva[/eluser]
Yes, and I told you its not CI specific. You can do that in normal PHP script no problemo.