• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] howto include anchor within normal $data-array

I have a view where I want to include dynamic - over the controller defined - links.

the following works fine:

$data['links'] = '<a href="./impress">Impress</a> | <a href="./test">test</a> ';


but I would like to use the "anchor"-function.

the following doesn't work:

$data['links'] = "&lt;?=anchor('impress', 'Impress')?&gt; | &lt;?=anchor('test', 'test')?&gt;";

How can I do that? ;-)

Try this:
$data['links'] = anchor('impress', 'Impress') . ' | ' . anchor('test', 'test');

cool - thanx! ;-)

[eluser]Majd Taby[/eluser]
UnrealMinds - the reason that doesn't work is because &lt;?=anchor('foo','bar'); ?&gt; is equivalent to &lt;?php echo anchor('foo','bar'); ?&gt;. So two things, first of all, when you're in php code (within &lt;?php and ?&gtWink, you don't use those tags, anything inside them is interpreted as php code. Also, anchor() returns the html, so you don't want to echo it out in the controller, instead you want to assign it, that's why you don't see echo in mironcho's code.

thanx for this description - I understand now

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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