| Welcome to WebmasterWorld Guest from 220.127.116.11 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|Adding <H2> to PHP Echo function |
| 3:04 pm on Feb 27, 2007 (gmt 0)|
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?
| 3:06 pm on Feb 27, 2007 (gmt 0)|
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';
| 3:14 pm on Feb 27, 2007 (gmt 0)|
Thanx for the fast response.
The page does loads but the output is:
| 3:23 pm on Feb 27, 2007 (gmt 0)|
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
| 3:27 pm on Feb 27, 2007 (gmt 0)|
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.
| 3:33 pm on Feb 27, 2007 (gmt 0)|
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.
| 3:38 pm on Feb 27, 2007 (gmt 0)|
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