span style question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gammaman
Forum Commoner
Posts: 45
Joined: Tue Feb 12, 2008 9:22 am

span style question

Post by gammaman »

How would I get span style to work in the following context. Mine has an error.

Code: Select all

 
echo "<span style = "color:red">" $firstname.'&nbsp;'.$lastname</span>.':';
 
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: span style question

Post by andym01480 »

Code: Select all

echo '<span style = "color:red">'.$firstname.'&nbsp;'.$lastname</span>.':';
Last edited by andym01480 on Thu Mar 20, 2008 3:22 pm, edited 1 time in total.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: span style question

Post by Zoxive »

gammaman wrote:How would I get span style to work in the following context. Mine has an error.

Code: Select all

 
echo "<span style = "color:red">" $firstname.'&nbsp;'.$lastname</span>.':';
 
You need to escape those quotes.

Code: Select all

echo "<span style = \"color:red\">{$firstname}&nbsp;{$lastname}</span>:";
OR

Code: Select all

echo '<span style = "color:red">' . $firstname . '&nbsp;' . $lastname . '</span>:';

______
andym01480 wrote:

Code: Select all

echo '<span style = "color:red">'.$firstname.'&nbsp;'.$lastname . '</span>:';
Still wrong at the end, </span> was not quoted.
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: span style question

Post by andym01480 »

oops too quickly done
Post Reply