homepage Welcome to WebmasterWorld Guest from 54.225.1.70
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Adding <H2> to PHP Echo function
Kangol




msg:3265422
 3:04 pm on Feb 27, 2007 (gmt 0)

Hi,
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?

Thanx.

 

mcibor




msg:3265427
 3:06 pm on Feb 27, 2007 (gmt 0)

You can echo only strings, so:

<? if ($mpfirstpost==1) echo '<h2>'.topic_title().'</h2>';?>

will work

Remember, that there is difference between
echo "text $variable text";
and
echo 'text $variable text';

Regards
Michal

Kangol




msg:3265441
 3:14 pm on Feb 27, 2007 (gmt 0)

Thanx for the fast response.
The page does loads but the output is:

Topic Title<h2></h2>

mcibor




msg:3265458
 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

Kangol




msg:3265467
 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.

Kangol




msg:3265473
 3:33 pm on Feb 27, 2007 (gmt 0)

Well,
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.

mcibor




msg:3265481
 3:38 pm on Feb 27, 2007 (gmt 0)

Will work

Regards
Michal

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved