I ask as you look at the comments and replies to your post, you think long
Today you want the italic option, tomorrow you want to change the display to
something else.  Now you have to go back and change ever place you set the
italic symbols to make your change. 

BUT if you use styles you can not only change the display to the desired
look in one location but you can have flexibility.


Let's say the comments are coming from a database and you want to display
the comment differently based on the contents of the comment.

In my example I have 3 different classes in the style. Now as I foreach over
the fake data array example, I simply pick the style to use based on each
matching criteria. While the static examples

#good_comment{font-style:italic; color: green;}
#bad_comment{font-weight:bold; color: red;}

$variable_from_database = array('good','bad','whatever');
Foreach($variable as $key)
        Echo 'Other Comments:';
        If(preg_match("/bad/i",'$key')){Echo '<div
        If(preg_match("/good/i",'$key')){Echo '<div
        If(preg_match("/whatever/i",'$key')){Echo '<div
        Echo '<br/>';

In the long term the flexibility allows you to make faster changes with a
higher degree, of what I like to call "smarter code". Yes the filters are
static, and I would not use static filters personally. It is meant as an
explanation, not a how to.

-----Original Message-----
From: Shreyas Agasthya [mailto:shreya...@gmail.com] 
Sent: Monday, October 18, 2010 6:10 AM
To: PHP General List
Subject: [PHP] Formatting an ECHO statement.


A bit of silly one but like my book says, there are no dumb questions, I am
asking it here.

If I have :


and I do:

echo 'Other Comments:' .$other. '<br/>

works perfectly well and prints the value. What if I want to, now, italicize
the value of $other with the above syntax? How do I achieve it?

I know we can do it this way : echo " I am <i>$other</i>"; but I want to
learn how to do it with the above syntax like I mentioned earlier.

Shreyas Agasthya

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to