Top Post

6/recent/ticker-posts

Learn PHP

 What is PHP?




PHP is a server-side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites. It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server. The basic structure of PHP

we can run PHP on windows with the help of Xamp server. we can download the Xamp from the given link


https://www.apachefriends.org/download.html


Install the Xamp and put the following source code


The basic code of PHP is following:

<? Php

Echo “This is Basic Code of PHP.”;

?>

 

The following statement will print

This is the Basic Code of PHP.


Many companies use PHP such as Facebook, WhatsApp Twitter, etc

 

Echo statement


We use the “echo” Statement in PHP to print something.

For Example:                                                                                       

<? Php

Echo “This is Basic Code of PHP.”;

?>

The following statement will print

This is the Basic Code of PHP.

Variables

 

In PHP Variables starts with “$” sign. We can make Variables by our self

Example:

$a = 34;

$v = 2;

$s = 45;

These are the examples of variables

Following is the Code of using Variables.

 

<? Php

$a = 34;

Echo $a;

 

?>

The following code will print the value of “$a” or our desired Variable.

 

Data Types


There are six Data Types in PHP.

These are the following.

1.    Integer

2.    Float

3.    String

4.    Boolean

5.    Array

In PHP we use the var_dump () function to know the type of a variable.

 

 

 

Following is the code to know the Data type of variable.

<? Php

$a = “NASIR ABBAS”;

$b = 23;

$c = 43.43;

$d = true;

$e = array (“1”, “3”, “4”, “5”);

Echo var_dump ($a). “<br>”;

Echo var_dump($b) . “<br>”;

Echo var_dump($c) . “<br>”;

Echo var_dump($d) . “<br>”;

Echo var_dump($e) . “<br>”;

 

?>

This will give following solution

string(11) "NASIR ABBAS"

int(23)

float(43.43)

bool(true)

array(5) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "3" [3]=> string(1) "4" [4]=> string(1) "5" 

Post a Comment

0 Comments