formatting using PHP

So you’ve gone though some of the tutorial, and you can make some nifty things in PHP. But the problem is, they all look like plain text. How do you jazz them up?

Formatting with PHP actually isn’t done with PHP, it’s done with HTML. You can do this in two ways. You can add the HTML inside of the PHP… or you can add the PHP inside of the HTML. Either way, make sure your file is saved as a .php or another file type that is allowed to execute PHP on your server.

HTML inside PHP

<?php

echo “<font color=red>Premal Katigar</font>”;

?>

PHP inside HTML

<font color=”red”>

<?php echo “Premal Katigar”; ?>

</font>

Loops in PHP

FOR Loop:

A FOR loop continues to process a block of code until a statement becomes false, and everything is defined in a single line, making it somewhat different to a WHILE loop. Read about FOR Loops

WHILE Loops:

Basically what a WHILE loop does is evaluate a statement as true or false. If it is true it executes some code and then alters the original statement and starts all over again by re-evaluating it. It continues to loop through the code like this until the statement becomes false

Examples :

for loop

for_loop

while loop

while_loop