| Welcome to WebmasterWorld Guest from 126.96.36.199 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|Adding <H2> to PHP Echo function |
I am tryng to add an H2 and css class to an echo function.
<? if ($mpfirstpost==1) echo topic_title();?>
This displays right the title of the post but I want to add an H2 to it. When I do it the page does not loads. I was thinking at
<? if ($mpfirstpost==1) echo <h2>topic_title()</h2>;?>
but its clearly an syntax error.
What is the right code?
You can echo only strings, so:
<? if ($mpfirstpost==1) echo '<h2>'.topic_title().'</h2>';?>
Remember, that there is difference between
echo "text $variable text";
echo 'text $variable text';
Thanx for the fast response.
The page does loads but the output is:
What do you have in function topic_title(), how do you echo the data there?
Because it's not a normal behavious of the script
I can think only that topic_title() sets some variables, which only then are echoed to page
Yes indeed. There is something going on with the topic_title(). If I replace it with another word it works well.
topic_title() is a function that gets the topic's title from a DB based on the topic's id.
I've come up with a lame solution:
<h2><? if ($mpfirstpost==1) echo topic_title();?></h2>
Duh... I should of thought of it before.
Thanx for your help.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved