I want to attach a php function for example: dtlan(text) < into <li> tag but i have one problem. i will show now my code and output:
echo "<a href=/".$array['id']."><li id='menu_".$array['id']."'>"
.dtlan($array['name'])."</li></a>";
output must be like this:
<a href='/2'> <li id='2'>wazaap </li></a>
actual output is:
wazaaap
<a href='/2'><li id='2'></li></a>
thats meens function runs first. and now my question how i can insert function into tags. thanks all and sorry for my ugly english 😀
I think (or I am quite sure) that the function doesn’t return the value, but echoes it instead.
Because the function is called during the process of building the string to echo. That means, the function has already echoed its value by the time the html is echoed. That’s why the function result is displayed before the html.
Either make the function return the value instead of echo it:
Or do like this:
First echo the first part. Then let the function echo its part. Then echo the closing part.
If you have the choice, I would choose the first.