Home
   <<
Starting in PHP
Post / Update: 30/04/10
Views: 1821

This is a class where we in fact begin to work in PHP. Go to the folder "www" from your local server and create a folder called "testes". Then open any code editor you like (Notepad, Dreamweaver, NetBeans, etc. I use Crimson Editor) and create a blank page with the name "escrever.php" and save to this folder "testes".

Inside your code editor, in that same page "escrever.php" write exactly that:

<?php
$minhaVariavel = ‘Olá’;
echo $minhaVariavel;
?>


We perceive that PHP printed (written) on the page the word 'Hello'. We use one of the most common procedures in Language that was displaying a value on the page. We have instantiate the value of a variable and print it. We can see below, we can use HTML within PHP when we are printing values:

<?php
$minhaVariavel = ‘Olá’;
echo ‘<h1>$minhaVariavel</h1>’;
?>


However, when the variable is printed with HTML, we perceive that the value "Olá" was not passed. That's because we put a variable in single quotes (apostrophes). To fix this, put it in double quotes so the variable $minhaVariavel will be correctly interpreted by PHP. So looks like this:

<?php
$minhaVariavel = ‘Olá’;
echo “<h1>$minhaVariavel</h1>”;
?>


Or this:

<?php
$minhaVariavel = ‘Olá’;
echo ‘<h1>’.$minhaVariavel.’</h1>’;
?>


Note that we had to concatenate the HTML tags with the variable in PHP using a point to connect them.

Remember that to access the page "escrever.php", you must type into your browser: http://127.0.0.1/testes/escrever.php. Only in this way will you see the page working properly.


For any doubts, you can access blogs, forums and the PHP page: http://www.php.net.
 PHP Course

Last post

Post/Update: 14/09/10

Structure, as its name implies, determines how a document or a particular composition are organized. In the case of control structures, it determines how flow the reading and processing in programming languages.

In the case of PHP, there are three...
 << See more



 Estou Hospedado na EazzyHost Design | Illustration | Programming