PHP Tutorial for Beginners

PHP FRONT TO BACK*

**What is PHP?
:- PHP: Hypertext Preprocessor(Recursive Acronym)
Server Side Programming/Scripting Language
Can be embedded directly within HTML (<?php?>)
Files use a “.php” file extension

** How Does PHP Work?
:- Client makes a request
Server runs PHP/extensions
Query database if needed
Load other files if needed
Result is sent back to client

** Why Use PHP?
:- Easy To Learn Freedom
Free & Open Source Frameworks
Great support Database Compatibility
Cross Platform

** What Can PHP do?
:- Create dynamic page content Interact with databases
Interact with files on the server Access control
Collect & process forms Encrypt data
Send/ receive cookies Almost anything else

** What Can You Build With PHP?
:- Basic Websites Content Management Systems
Blog Type Websites Membership Websites
Shopping Carts Search Engines
Social Networks Backend APIs

*** Install XAMPP Apache+MariaDB+PHP+Perl)(Latest version 7.1.1)
** What is XAMPP?
:- XAMPP is the most popular PHP development envirnment

  • Install XAMPP his after open It and start Apache and MySQL go browser and search –
    https://loclalhost(here uses only htdocxs file your xampp file)

** Variables
:- Prefix $
Start with a letter or an underscore
only letter, numbers and underscores
Case sensitive

** Data types
:- String (ex- 12, 0, -34 etc.)
Integers (ex- 25.2654, 2.12, 41.54 etc.)
floats
Booleans (ex- true/false)
Arrays (ex- multiple values in one single variable)
Objects (ex- hold programming objects)
Null (ex- hold only one value- NULL)
Resource (ex- special variable that hold references to resources external to PHP)

  • some Data type class
    • $Output = ‘………’; (………= You can use any word which you shown in desktop )
    • $num1 = 4; ()
    • $num2 = 10;
    • $sum = #num1 + $num2;
    • $strings1 = ‘…….’;
    • $strings2 = ‘…….’;
    • $greeting = string1. ”. $strings.’!’;
    • $greeting2 = “$string1 $string2”;
    • $string3 = ‘They\’re Here”;
      :- define(‘GREETING’, ‘Hello Everyone’, true);
      :- echo greeting;
  • Array- basically variable that holds multiple values these are three types:-
    1) Indexed
    2) Associative
    3) Multi-dimensional

** 1)Indexed
some Indexed class
– $people = array(‘……..’, ‘………’, ‘……..’;
:- echo $people[3];

- $ids = array (23, 55, 12);
:- echo $ids[2];

- $cars= ['honda', 'Toyota', 'Ford';]
:- $cars[3]= 'Chevy';
:- echo $ids[3];

** 2) Associative arrays
– $people = array(‘…….’=> 35, ‘……..’=> 32, ‘……..’ => 27);
:- $ids = [22 => ‘…….’ ];
:- echo $ [‘……’];

** 3) Multi Dimensional
$cars = array(
array(‘Honda’, 20, 10),
array (‘Toyota’, 30, 20),
array (‘Ford’, 23, 12),
);
echo $cars[1][2]