conditional colouring of a variable value

In PHP for example if $anumber>100, $anumber's colour should be red otherwise blue.
ssalameeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
u can try:

$color = ($anumber>100)? "#FF0000" : "0000FF";

Open in new window

ref:
http://www.w3schools.com/html/html_colors.asp
0
Ray PaseurCommented:
If you're new to PHP and want to learn the language, this article may be helpful.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

Strictly speaking, variables have no color attribute.  They are just placeholder names that point to data locations in memory.  PHP is a server-side technology that creates strings of data and sends these strings to the client browser.  The browser renders these data strings, usually in the form of HTML, CSS and JavaScript.  Since the browser is responsible for visual rendering, PHP would, of necessity, need to interact with the browser via CSS in order to color some of the data red or blue.  Here is an example:
http://iconoun.com/demo/temp_ssalamee.php?a=99
http://iconoun.com/demo/temp_ssalamee.php?a=101
<?php // demo/temp_ssalamee.php

/**
 * http://www.experts-exchange.com/questions/28700436/conditional-colouring-of-a-variable-value.html
 */
error_reporting(E_ALL);

// SET THE DEFAULT COLOR
$c = 'blue';

// IF THERE IS A REQUEST, RESET THE COLOR
$a = !empty($_GET['a']) ? (int)$_GET['a'] : 0;
if ($a > 100) $c = 'red';

// SHOW THE VALUE OF VARIABLE "$a" USING THE CSS COLOR OF "$c"
echo PHP_EOL
. '<h1 style="color:'
. $c
. '">'
. $a
. '</h1>'
. PHP_EOL
;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.