• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse error: syntax error, unexpected T_ECHO

#1
[eluser]Mainboard[/eluser]
i have a little problem with codeigniter, in the view when i try to call some variables i have this problem, this is my code.

My View.

Code:
<? php foreach ($menu_enc as $menue): ?>
Code:
&lt;? '<a class="current">destino;'>' echo $menue->nombre_enc; '</a>' ?&gt;
Code:
&lt;?php endforeach; ?&gt;

i try with add echo at the start on the phrase like this

Code:
&lt;? echo '<a class="current">destino;'>' echo $menue->nombre_enc; '</a>'; ?&gt;

but not works, and i don't know why in the preview doesn't appear the href="'echo $menue->link;

so i what i can do? i know that is a some problem with the syntax but i can't find the correct syntax

#2
[eluser]jmadsen[/eluser]
Thank you for moving your question over here.

CodeIgniter syntax is php syntax; you need to do things in the same way.

Code:
&lt;?php '<a class="current">destino;'>' echo $menue->nombre_enc; '</a>' ?&gt;

should read:

Code:
&lt;?php echo '<a class="current">' . $menue->nombre_enc . '</a>'; ?&gt;

I don't understand "destino" - is this the href="" part, and does it come from your database?

Grrr..the forum is making a mess of the html code!!

If $menue->destino is your href, then use:

Code:
href="    "
... put
Code:
'.$menue->destino.'
inside the quotes

----

Here are some more resources for understanding "concatenation":

An easy to read tutorial:
http://phphowto.blogspot.com/2006/12/con...rings.html

The manual:
http://php.net/manual/en/language.operators.string.php

#3
[eluser]Anonymous[/eluser]
This should work

Code:
&lt;?php
  foreach ($menu_enc as $menue):
    echo "<a href='' class='current'>destino $menue->nombre_enc </a>"; ?&gt;  
  endforeach;
?&gt;


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.