LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-08-2010, 08:11 PM   #1
latino
Member
 
Registered: Aug 2003
Location: Puerto Rico
Distribution: Centos 6.6
Posts: 142

Rep: Reputation: 15
Question how to echo a variable with font color (php)


Hi:
Sorry if this sounds like a simple question but I have tried several alternatives none works.

For example:
Code:
echo "<font color='red'>".$variable."</font>";
I need to echo a variable like this one
echo $variable;

but need to be able to specify color (like black).

How I can do this?

TIA

Last edited by latino; 02-08-2010 at 08:18 PM.
 
Old 02-08-2010, 08:31 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
Quote:
Originally Posted by http://www.w3schools.com/HTML/html_fonts.asp
The <font> Tag Should NOT be Used

The <font> tag is deprecated in the latest versions of HTML (HTML 4 and XHTML).

The World Wide Web Consortium (W3C) has removed the <font> tag from its recommendations. In future versions of HTML, style sheets (CSS) will be used to define the layout and display properties of HTML elements.

The Right Way to Do It - With Styles
So, as stated, use styles. An example of inline might be
Code:
echo "<div style=\"color: red;\">$variable</div>";
Or if you have it linked to a style sheet, you could use
Code:
echo "<div id=\"myStyleName\">$variable</div>";
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About color font in script PHP lrios Programming 1 01-28-2010 02:39 PM
[SOLVED] problem with echo and variable crts Programming 18 01-04-2010 05:37 PM
echo variable problem Ejdaha Linux - Newbie 5 02-16-2009 11:42 AM
How to change font color and font size in terminal ? wlaw Linux - Newbie 3 05-15-2007 08:57 PM
How to echo results of variable BabaKali Linux - Newbie 7 11-10-2004 12:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration