In this post, I am covering the PHP basics. By reading this post you will learn PHP basics easily.
PHP Introduction:
- PHP Stands for “Hyper-Text Pre-Processor”.
- It was created by Rasmus Lerdorf in 1994.
- It is a server-side scripting language.
- php is used to create web applications.
- PHP is used to create dynamic websites
Print functions in PHP
There are two functions in PHP which you can use to print.
- echo
echo is a little bit faster in loading by the browser.
Comments in php:
// double forward slash is used for single line comment in PHP.
/* your comments here */
forward slash Steric and Steric forward slash are used for multiline comments in PHP.
Declaring Variables in PHP
Dollar sign is used to declare variables in PHP.
You must write dollar sign with variable name to declare variable in PHP.
For example:
If I want to declare variable a then I have to write:
$a;
Syntax of PHP Code:
<?php
php code is written here
<?
Data types in PHP:
Following are the data types that are used in php.
String:
String is written within double quotes or it can be written in single quotes also.
example:
$name = “Coding is fun”;
$name = ‘Coding is fun’;
Integer:
Integer is written without quotes.
example:
$name = 20;
float:
float is written in decimal format.
example:
$name = 20.3;
Boolean:
Boolean is written in the form of true and false.
true is for 1.
false is for 0
Array in PHP:
By declaring array first you have to create a variable to store that array then you have to write a array() function and enter values inside that function separated by comma.
In PHP array is diclared like.
$names = array(“Jonny”,”Marry”,”Maly”);
Printing above array
echo $names[‘0′,’1′,2’];
Like us on Facebook to learn more about new free online courses and other educational materials for free