Welcome Guest, Not a member yet? Register   Sign In
Alternative Control Structures
#1

[eluser]Milos[/eluser]
Hi all.

I just started to use CodeIgniter so I can't understand something very basic.

I am doing tutorials...

Anyway code looks like this: (this is from a view "home.php")


<?php foreach ($rows as $r) : ?> //why are we closing PHP tag here?

<h1>&lt;?php echo $r->title; ?&gt;</h1>
<div>&lt;?php echo $r->contents; ?&gt; //why I can't use alternative syntax &lt;?= $r->contents?&gt;

&lt;?php endforeach; ?&gt; // again why are we opening and closing PHP tag?

So what confuses me is that normal PHP short tags should be like this:

&lt;?php foreach ($rows as $r) : // we are opening a foreach structure

//dosomething

endforeach; ?&gt; // we are closing a foreach structure

So this makes for me a second problem to understand echo statement used inside.

I didn't find so many things to read about this.

Also I wander what is the code in CodeIgniter itself that allows this behavior, since if I look at it I may understand this better.

Thanks


Messages In This Thread
Alternative Control Structures - by El Forum - 09-21-2010, 12:38 PM
Alternative Control Structures - by El Forum - 09-21-2010, 01:03 PM
Alternative Control Structures - by El Forum - 09-21-2010, 02:57 PM
Alternative Control Structures - by El Forum - 09-21-2010, 03:03 PM
Alternative Control Structures - by El Forum - 09-21-2010, 03:39 PM
Alternative Control Structures - by El Forum - 09-21-2010, 07:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB