基本的PHP问题

How would I make the font inside a php tag blue.

<?php $colors = array(blue); ?>
<hr />

<br />
<?php echo $colors [0] ; ?>

The array is very simple but I do not know how to change to font color. The output will echo "blue" it is in black font. However, I am going to have the array with several different colors (6). I figured if I seen an example that I would understand it. That is the reason I only provided one example.

php doesn't affect style, but you could always print it inside a css statement, something like

<p style="color:<?php echo $colors[0];?>">colored text here</p>

Edit: better yet, print a class name so you could keep a separated style sheet and not use inline style, like class="<?php echo $classblue;?>"

You can't set the colour of anything inside a PHP tag. It is executable code.

When the code is executed, then it may output something that could have a colour. This is usually HTML.

To make something blue in HTML:

  1. Decide why it should be blue
  2. Generate appropriate semantic HTML to describe that reason
  3. Write CSS with a selector that matches that semantic HTML and color: blue; in the rule-set.

Also you have to use HTML,

<span style="color: <?php echo $colors[0]; ?>">Hello</span>