PHP Basics
What is a syntax? Laical spoken, the syntax represent a group of rules that every code has to fulfill.
PHP code has to be inside key words (tags)
<?php
/*.....here you put the code....*/
?>
or short
<?
/*.....here you put the code....*/
?>
Every code order, definition variable has to be ended with ;
How to save PHp pages?
If you intend to put PHP code into your HTML pages and want the server or web browser to show your page right you have to use .php extension, instead of standard .html, for your pages. For example, instead of index.html it should be written index.php
Variables
It is used for temporary saving a certain values (a number, text...). The value, saved in variable, can be used many times after, trough the whole code.
Variables are defined in this way: $variable_name = value;
The dollar sign in front of the variable is bound. Note: variable names are case sensitive. For example, $name and $Name are two different variables.
The rules you have to respect when naming variables are:
PHP variables have to begin with the s letter or "_" sign.
Name can contain next signs a-z, A-Z, 0-9 or _.
Example: $my_variable.
It is alright to separate them using capital and small letters. Example: $myVariable
|