PHP Tutorial

Today, We want to share with you PHP Tutorial.In this post we will show you PHP Tutorials For Beginners Step By Step With Example, hear for PHP Tutorials – An Ultimate Guide for Beginners we will give you demo and example for implement.In this post, we will learn about PHP Tutorials for Beginners with an example.

PHP Tutorial

There are the Following The simple About Step-by-Step PHP Tutorials for Beginners Full Information With Example and source code.

As I will cover this Post with live Working example to develop PHP Programming Language – PHP Tutorial for Beginners, so the PHP :How To Start Programming is used for this example is following below.

Basic PHP Tutorials – The PHP Hypertext Preprocessor (PHP) is a simple programming language that allows all the fresh & new web developers to make a dynamic Data content that interacts with MySQL & MySQLi databases.

Characteristics of PHP

  • Simplicity
  • Efficiency
  • Security
  • Flexibility
  • Familiarity

Hello World using PHP

      <title>Simple PHP Hello World Example</title>
      <?php echo "Hello, World!";?>


PHP Tutorials Index

Sr.No. Topics
1 PHP Introduction For Beginners
3 PHP Software Requirement
4 PHP WAMP Installation
5 PHP XAMPP Installation
6 PHP Syntax
7 PHP Comments
8 PHP Variables
9 PHP $ and $$ Variables
10 PHP Super global variables
11 How to swap two numbers in PHP
12 PHP Constant
13 PHP:Magic Constant
14 echo and print in PHP
15 PHP Data Types
16 PHP Form
17 GET Method
18 POST Method
19 Form action
20 PHP Display result in Textbox
21 Multiple submit buttons php different actions
22 Add two textbox values and display the result in third textbox
23 PHP Operators
24 PHP Arithmetic Operators
25 PHP Assignment Operators
26 PHP Comparative Operators
27 PHP Logical Operators
28 PHP Operators Precedence
29 PHP Conditional Statement
30 PHP if Statement
31 PHP if-else Statement
32 PHP if elseif else Statement
33 PHP Switch Statement
34 PHP calculator
35 Profit and Loss
36 What is Loop
37 PHP For Loop
38 Print star pattern in PHP
39 Create table using for loop in PHP
40 PHP While Loop
41 PHP Do While Loop
42 PHP Foreach Loop
43 PHP String
44 PHP Numeric Functions
45 PHP Tutorial PDF For Beginners
46 PHP isset function
Read Also:  Time Ago Function Helper Class in PHP

php array length

array length php Example:PHP count() Function

echo count($players);

PHP array printing using a loop

$length = count($players);
for ($i = 0; $i < $length; $i++) {
  print $players[$i];

How to get Array length in PHP?

php count vs sizeof

using count

$player_nums = array (5,7,9,11,13);
echo "The size of players = ", count($player_nums);

using sizeof

$player_nums = array (5,7,9,11,13);

echo "The size of players = ", sizeof($player_nums);

PHP Date & Time Function with Example

php timestamp

Getting a list of available time zone identifiers

$timezone_list = DateTimeZone::listIdentifiers();
foreach($timezone_list as $key => $list){
	echo $list . "<br/>";

PHP set Timezone Programmatically

date_default_timezone_set ( string $timezone_identifier );

changes/updates the default time zone to Asia/Calcutta and displays the time again.

echo "PHP :- The time in " . date_default_timezone_get() . " is " . date("H:i:s");

echo "The time in " . date_default_timezone_get() . " is " . date("H:i:s");

Getting Current Timestamp in PHP

using time()

$active_new_time_stamp = time();
echo $active_new_time_stamp;

using strtotime()

$active_new_time_stamp = strtotime("now");
echo $active_new_time_stamp;

using mktime()

$active_new_time_stamp_by_mktime = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"));
echo $active_new_time_stamp_by_mktime;

using microtime()

$active_new_time_stamp_string = microtime();
echo $active_new_time_stamp_string;
$active_new_time_stamp_float = microtime(TRUE);
echo $active_new_time_stamp_float;

using Date

$active_new_time_stamp_fndate = date("U");
echo $active_new_time_stamp_fndate;

PHP Date/Time to Timestamp Conversion

$date_from_timestamp = date("d-m-Y",$active_new_time_stamp);
echo "Your Formatted date from timestamp:" . $date_from_timestamp;

php variable scope

Local variable

    function local_var()  
        $parms = 98;  //local variable  
        echo "Local variable declared inside the function is: ". $parms;  

Global variable

    $god_name = "Krishna Vashudev";        //Global Variable  
    function global_var()  
        global $god_name;  
        echo "Variable inside the function: ". $god_name;  
        echo "</br>";  
    echo "Variable outside the function: ". $god_name;  

Static variable

    function static_var()  
        static $parms1 = 3;       //static variable  
        $parms2 = 6;          //Non-static variable  
        //increment in non-static variable  
        //increment in static variable  
        echo "Static: " .$parms1 ."</br>";  
        echo "Non-static: " .$parms2 ."</br>";  
	//first function call  
    //second function call  

Function parameters (local scope)

function getBawlers() {
    $player = 'bhuvenswar';

    $getBats = function () {
        // $player cannot be accessed inside here
        $batsmen = 'virat';

    // $batsmen cannot be accessed outside here

php get ip address

php get ip, get ip php Examples

Read Also:  PHP AJAX Live Search Box Autocomplete Using MySQL Database

How to Get IP Address of User in PHP?

function retriveUserIpAddr(){
        $ip_address = $_SERVER['HTTP_CLIENT_IP'];
        $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
        $ip_address = $_SERVER['REMOTE_ADDR'];
    return $ip_address;

echo 'Fetch User Real IP - '.retriveUserIpAddr();

Get the Visitors(Users) IP Address

$ip_Address = $_SERVER['REMOTE_ADDR'];  
echo "Here is thereal IP Address of Visitors : ".$ip_Address;  

Get the IP address of the website

$pakainfoipAddress = gethostbyname("");  
echo "Here is the IP Address of pakainfo : ".$pakainfoipAddress;  
echo "</br>";  

$infinityknow_ip_address = gethostbyname("");  
echo "Here is the IP Address of infinityknow : ".$infinityknow_ip_address;  

PHP json encode

PHP JSON Encode and Decode Examples

Read Also:  Install WhatsApp web On iPad Without iPhone Tutorials

PHP json_encode()

$players_name = array("virat","dhoni","sachin");
//returns ["virat","dhoni","sachin"] 
$player_json_format = json_encode($players_name);
print "JSON Formatted String:" . $player_json_format;
//returns {"0":"virat","1":"dhoni","2":"sachin"}
$obj_json_format = json_encode($players_name, JSON_FORCE_OBJECT);
print "<hr/><hr/>JSON Object:" . $obj_json_format;
//returns [ "virat", "dhoni", "sachin" ]
$strJsonFormat_with_space = json_encode($players_name, JSON_PRETTY_PRINT);
print "<hr/><hr/>JSON Formatted String with white space:" . $strJsonFormat_with_space;

Example: json_decode()
$str_json_array_decoded = json_decode($player_json_format);
print "<hr/><hr/>Resultant decoded array from JSON array:<hr/>";
print "<pre>";
print "</pre>";

$str_objJson_decoded = json_decode($obj_json_format);
print "<hr/><hr/>Resultant decoded object data from JSON object:<hr/>";
print "<pre>";
print "</pre>";

$str_jsonAry_decoded = json_decode($obj_json_format,true);
print "<hr/><hr/>Resultant decoded array data from JSON object:<hr/>";
print "<pre>";
print "</pre>";

encapsulation in php

Encapsulation in PHP


class member

public $name;
public $age;

	function __construct($n, $a)



	public function setAge($ag)




	public function display()


	echo  "welcome ".$this->name."<br/>";

	return $this->age-$this->ag;



$member=new member("Sejal",35);
echo "You are ".$member->display()." years old";

   class BANKATM {
      private $memberid;
      private $atmpin;
      public function PinChange($memberid,$atmpin) {
               ---------added your code-----
      public function CheckBalance($memberid,$atmpin){
               ---------added your code-----
      public function miniStatement($memberid) {
               ---------added your code-----
   $obj = new BANKATM();
   $obj ->CheckBalance(89985356851234,1**3);

Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about How to learn PHP: a 15 days program for beginners?.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.