Monday, 6 March 2023

Server-Side Scripting (PHP)

Server Side Scripting (PHP)

PHP(Hypertext Preprocessor)-open source general purpose language.

Especially for web development.

PHP runs on various platform(Linux,Unix,MacOSX,Windows)

PHP is compatible with almost all servers (XAMMP,Apache,NGINX,Lightpad)

PHP Supports wide range of database,Free and open source,Easy to learn.

 

Features of PHP.

1)Simple

2)Interpreted

3)Faster

4)Open Source

5)Platform Independent

6)Case sensitive

7)Error Reporting

8)Real time access monitoring

9)Loosely typed language.

 

echo keyword is used to display text on webpage.

PHP variable

$ keyword is used to declare variable in php.

Variable names are case sensitive

Variable names can not start with number.

Must start with character or alpha-numeric character

Variable scope-local,global,static

 

PHP data types

1)   String                 2)Integer           3) Float

4)Boolean             5)Array              6)NULL

 

PHP comments

Comments are statements which are not visible in output.

a)   Single line comment- //

b)  A multiline comment- /*…….*/

 

Control structure in PHP

1)if statement

2)if-else statement

Loop  structure – used to execute the same block of code repeatedly as long as certain condition is satisfied.

1)For loop

2)foreach loop

 

PHP string Function-

A string is series of characters

A function is a block of statement that can be used repeatedly in a program

 

PHP Arrays

An array is special variable ,which can hold more than on value at a time.Stores multiple values in one single variable.

 

Types of array

1)   Indexed array-Arrays with a numeric index

2)   Associative arrays-Arrays with named keys

3)   Multi-dimensional arrays-Arrays containing one or more arrays

 

PHP Form

The PHP superglobals $_GET and $_POST are used to collect form data.

$_GET is an array of variables passed via the URL parameters.

$_POST is an array of variables passed via the HTTP POST method.

 

$-GET-

$_GET is an array of variables passed via the URL parameters.

Information sent from a form with GET method is visible to everyone.

Limits on the amount of information to send

Used to sending non sensitive data

Never used to sending password and sensitive information.

 

$_POST

$_POST is an array of variables passed via the HTTP POST method.

Information sent from a form with GET method is not visible to anyone.

No limits on the amount of information to send

used to sending password and sensitive information.

Variables are not displayed in the URL.

 

 

Cookies- is a small text file that the servers sends on the user’s computer.

Used to identify user on its machine and track activities created on the user computer.

 

Session-Used to store user information on server to track user activities.

It helps web application to maintain user information on all pages.

 

 

 

 

 

 

 

 

 

 

 

 

 


No comments:

Post a Comment