PHP basics tutorial

What is a syntax? Laically spoken, the syntax represent a group of rules that every code has to fulfill.

PHP code has to be inside of key words (tags):

<?php
/*.....here you put the code....*/
?>

or short

<?
/*.....here you put the code....*/
?>

Each 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, through the whole code.

PHP variables are defined in this way: $variable_name = value;

The dollar sign ($) in front of the variable is a bound.

Note: variable names are case sensitive. For example, $name and $Name are two different variables.

The rules you have to follow while 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 _.
  • Variables with more than one word should be divided with _ like $my_variable
  • It can also be divided using upper and lower case letters like $myVariable

Hello. How can we help you?

back btn

Order our service

This field is required
Web design Web development Web application Internet marketing Copywriting Graphic design This field is required
This field is required

back btn

Join us!

This field is required
UI/UX designer Community Manager Front-end Developer Back-end Developer Graphic Designer Copywriter SEO This field is required
Upload CV/Portfolio
This field is required

back btn

We are here for you.

This field is required
This field is required