PHP Tutorial For Beginners Step By Step With Example Session-1
What is PHP
PHP is Open Source server-side programming / Scripting language that is especially suited for web development and can be embedded into HTML.
PHP stands for Hypertext Preprocessor but it’s original name, Personal Home Page. It was created by Ramsum Lerdorf in 1994.
PHP runs on various platforms Windows, Linux, Unix, Mac OS X, etc.
PHP is compatible with almost all servers Apache, IIS, etc.
At Present in 2017 Php 7.2.0 is latest version of PHP
PHP File Extension .php
What we can do with PHP
- Generate Dynamic Page
- Handle button clicks, radio button
- Create Database Application
- Client/server Application
- Student Registration
- Online Course
- Online Shopping cart
- Chat Rooms
How PHP Works
- Operating System – Windows, Linux, Mac etc.
- Web Server – XAMP, WAMP, MAMP etc.
- §XAMP – Apache + MariaDB + PHP + Perl
- Editor/IDE – NotePad, NotePad ++, NetBeans, Brackets, Eclipse etc.
- Web Browser – Chrome, Firefox etc.
Basic Structure of PHP
Basic Structure of PHP
Variables are containers which is used to store information.
Type of Variables: –
- Local Variable
- Global Variable
- Static Variable
In PHP, variable names begin with $ sign, followed by a name.
- Variable starts with $ sign.
- Variable name only starts with a letter, an underscore ( _ ).
- Variable name cannot start with a number.
- It is case sensitive which implies that the variable num in lowercase is different from variable NUM in uppercase.
- Do not use Predefined constant name e.g. PHP_VERSION , PHP_OS etc.
- Do not use reserved keywords. e.g. else, if etc.
PHP can store all type of data in variables. Before using a variable in PHP, assign a value to it so PHP will create that variable and store data in it. That means we have to assign data to a variable before attempting to read a variable’s value.
- $roll = 256;
- $price = 25.50;
- $name = “Geeky Shows”;
Note – If a variable is created without a value, it is automatically assigned a value of NULL.
Internal Data Types
In other language, you need to specify the exact data format of each variable, but PHP handles that for you.
- Integer – It can hold whole number. Ex: 12, 0, -34 etc.
- Float/Double – It can hold floating point number. Ex: 25.2654, 2.12 etc.
- String – It can hold text or group of characters. Ex: – “Geeky Shows” etc.
- Boolean – It can hold true/false value.
- Array – It can hold multiple values in one single variable.
- Object – It can hold programming objects.
- Resource – It is special variable that hold references to resources external to PHP.
- NULL – It can hold only one value – NULL .