How to style an echo with CSS?

-2

For example: I want to display a formatted number of the database:

echo number_format($saldo, 2, ',', '.');

Then echo writes: 8,944,664.00

I want to know how to use the css in this condition ... to show the part of the screen that I want, the color I want, etc. etc.

I learned this way: echo "<div class=\"saldo\">$saldo</div>";

I'm not sure what to do with CSS,     

asked by anonymous 26.05.2016 / 06:34

3 answers

3

Put the content to be printed under single quotes, so you can easily double-quote the content:

echo '<div class="saldo">'.number_format($saldo, 2, ',', '.').'</div>';

Or even this way:

echo '<div style="color:red">'.number_format($saldo, 2, ',', '.').'</div>';
    
26.05.2016 / 07:11
2

Since echo allows several parameters, it can be used as follows:

First form (commas and commas) :

echo "<div class=\"saldo\">", number_format($saldo, 2, ',', '.') ,"</div>";

Second form (quotation marks and periods) :

echo "<div class=\"saldo\">". number_format($saldo, 2, ',', '.') . "</div>";

Third (echo shortcut / short open tag) PHP> = 5.4.0:

<?=number_format(12930, 2, ',', '.');?> 

The echo , allows you to pass several parameters. The first form form would be the most common, because when you have several parameters, the normal is that they are separated only by commas, and in that case would be interpreted as a priority. But what should be taken into account is that echo is not properly a function, but a constructor of the language itself.

The third approach does not have to be bound to echo , simply abertura + variavel + fecho .

    
14.04.2017 / 19:18
1

You can also use the extension .phtml in your file and work as if it were an html page just put between <?php ?> or <?= ?> codes in php (backend).

    
14.04.2017 / 20:02