Language:

PHP Fusion + Html

5 February 2011 | In Web | 399 views | By

Click & share: 


For starting to learn PHP, tem de perceber first como este se funde com o HTML. I.e., If we have an HTML page, and we want a simple functionality developed in PHP, We do not need to write the
the whole page in PHP. Seria totalmente inútil do o output de uma página inteira de HTML, just to show the hours, or the date.

Vamos então perceber como tudo works!

<html>
<body>
<!-- Exemplo de um output em HTML -->
Olá pessoal! Esta é uma área normal de <b>HTML</b>! <br>
<?
// Exemplo de um simples output em PHP
echo "Esta área já é dentro do <b>PHP</b>.";
?>
</body>
</html>

This file is called “exemplo1.php”.

In this example we have a normal page with the normal header and some HTML tags. Then we also have the area containing PHP code. This area is bounded by tags <? (beginning) and ?> (order). In this example, the code uses the function”echo” to send the output to the final page, get the HTML code form. The result of this “echo” wilecho:

This area is already inside of PHP.

When the word PHP is written in BOLD.

Note: ALL INTRUçOS Are TERMIDADAS With The Character ; (semicolon) This character indicates the interpreter when just a instruçao, and when he must wait another intruçao. The exception of this case is when a block
PHP code only contains a single statement, and in this case include whether or not the ‘;’ .

Just as there are HTML comments delimited by <!– and –>, in PHP you can also comment on parts of a code. For such, If you want to comment on a single line, We use the characters ‘//’ to comment on the
that line will not be processed. For a block of lines, We use tabs “/*” at the beginning of the block, and “*/” to close the comment.

Example:

<?
// Uma linha de comentario ..
/*
Um Simples
bloco de
comentario !!!
*/
?>

Exercise 1:

Uses PHP Echo function interchangeably and the normal text in html to make the output of the following phrases:

Html:
The first line is <u>normal</u>.<br>

PHP:
The second, the line is already written by <b>PHP</(b)>.<br>

Html:
Herein, comes a <font color = # FF0000>3do more complex</font>…<br>

PHP:
And soon the <font color = # 00FF00>follow</font>, the 4th <font color = # 0000FF>still
more</font> complicated!<br>

If all goes well, the result is the following:

The first line is normal.
(with the “normal” underscore)

The second line, It is written by PHP.
(the “PHP” the bold)

Herein, comes a third more complicated…
(“3do more complex” the Red)

And shortly thereafter, the 4th even more complicated!
(“follow” the Green and “even more” the blue)

If you managed to do this, These are on the right track! :-)

Summary:
PHP can be just a piece of code that gets in the way of HTML tags and is
delimited by tags <? and ?>.

In Ivaiporã-PR, Computer engineer, Workgroup Administrator Tips in General. Passionate about technology and Informatics.



A bit about us

    The Group generally appeared in Tips 2007 from innovative ideas on troubleshooting problems faced daily by those who use the technology and computer science, both ordinary users and technicians. But where did, why and what is the purpose of this site?

Click here to read!

Siga o Dicas em Geral no Google+

Video of the week