Welcome Guest, Not a member yet? Register   Sign In
In views use <?php echo $title; ?> or <?=$title?> ?
#4

[eluser]EugeneS[/eluser]
[quote author="juanvillegas" date="1284332599"] just because you can't use it for all your php sentences.[/quote]

what do you mean by "all php sentences" ? Smile

this construction used just to show some data and this construction is part of the "PHP’s alternative syntax".

this alternative syntax allows views look like template but not like another controller or php of 90's with the mix of php and html

up to me it's good rule to not use in views objects etc and have deals only with the variables and arrays and use alternative syntax like:

Code:
<?=$variable_name;?>

<? foreach($some_array as $key => $value): ?>
   <div>&lt;?=$key;?&gt;</div>
&lt;? endforeach; ?&gt;

&lt;? if(isset($something)): ?&gt;
   <div>&lt;?=$some_variable;?&gt;</div>
&lt;? endif; ?&gt;

this way for sure looks better in views than ugly mix of php and html
Code:
&lt;?php
   if(isset($something))
   {
       echo '<div>'.$some_variable.'</div>';
   }
?&gt;

or even more ugly way

Code:
&lt;?php
   if(isset($something))
   {
?&gt;
    <div>&lt;?php echo $some_variable; ?&gt;</div>
&lt;?php
   }
?&gt;

complete mess Smile

etc Smile


Messages In This Thread
In views use &lt;?php echo $title; ?&gt; or &lt;?=$title?&gt; ? - by El Forum - 09-12-2010, 12:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB