Quick Reference Study Notes for PHP Web Development (Advanced)

PHP Web Development

PHP (PHP Hypertext Preprocessor) is a server scripting language and a powerful tool for making dynamic and interactive Web pages. PHP scripts are executed on the server. It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix and Microsoft SQL Server. PHP is free to download and use. Following are some commonly used terms in the world of php web development with description:



used to send a raw HTTP header


Checks if or where headers have been sent


Send a cookie


Get or Set the HTTP response code


Remove previously set headers




A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too.

Create a cookie

setcookie(name, value, expire, path, domain, secure, httponly);


Global variable to retrieve cookie variables.

Delete a Cookie

To delete a cookie, use the setcookie() function with an expiration date in the past:


PHP Session

PHP Session

A session is a way to store information (in variables) to be used across multiple pages. Unlike a cookie, the information is not stored on the users computer


Function to Start a PHP Session


Global variable to set/retrieve session variables like $_SESSION["favcolor"] = "green";


PHP Magic constants


The current line number of the file.


The full path and filename of the file. If used inside an include, the name of the included file is returned.


Returns the function name, or {closure} for anonymous functions.


returns the class name as it was declared (case-sensitive)


returns the name of the class alongwith the name of the function


HTTP - Status Codes

1xx: Informational

It means the request has been received and the process is continuing.

2xx: Success

It means the action was successfully received, understood, and accepted

3xx: Redirection

It means further action must be taken in order to complete the request.

4xx: Client Error

It means the request contains incorrect syntax or cannot be fulfilled.

5xx: Server Error

It means the server failed to fulfill an apparently valid request.


HTTP - Requests Methods


The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and should have no other effect on the data.


Same as GET, but it transfers the status line and the header section only.


A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.


Replaces all the current representations of the target resource with the uploaded content.


Removes all the current representations of the target resource given by URI.


Establishes a tunnel to the server identified by a given URI.


Describe the communication options for the target resource


Performs a message loop back test along with the path to the target resource.


PHP Filesystem Functions

fopen (file, mode)

Opens file or URL

readfile (file)

Outputs a file

fread (handle, len)

Binary-safe file read

fwrite (handle, str)

Binary-safe file write

clearstatcache ()

to clear the information that PHP caches about a file

copy (source, dest)

Makes a copy of the file source to dest

fclose (handle)

Closes the file pointed to by handle.

fgets (handle, len)

Gets a line from file pointer.

file (file)

Reads entire file into an array

filemtime (file)

Gets file modification time

filesize (file)

Gets file size

file_exists (file)

Checks whether a file or directory exists


PHP fopen() Modes




Read and write, prepend


Write, truncate


Read and write, truncate


Write, append


Read and write, append


PHP Options and Information

extension_loaded ( string $extName )

Finds out whether the extension is loaded.


Gets the name of the owner of the current PHP script


Returns an associative array with the names of all the constants and their values


Returns an array with the names of all modules compiled and loaded


Returns an array with the names of included or required files


Returns active resources


Gets PHP's process ID


Gets all configuration options


Gets the value of a configuration option


Restores the value of a configuration option


Sets the value of a configuration option


Outputs information about PHP's configuration


Gets the current PHP version




used to access global variables from anywhere in the PHP script (also from within functions or methods).


holds information about headers, paths, and script locations.


used to collect data after submitting an HTML form.


used to collect form data after submitting an HTML form with method="post"


used to collect form data after submitting an HTML form with method="get"


It can be used to upload files from a client computer/system to a server.


Environment variables.


To retrieve the cookie variables


To retrieve the session variables


Superglobals ($_SERVER)


Returns the filename of the currently executing script


Returns the version of the Common Gateway Interface (CGI) the server is using


Returns the IP address of the host server


Returns the name of the host server


Returns the server identification string


Returns the name and revision of the information protocol


Returns the request method used to access the page (such as POST)


Returns the timestamp of the start of the request


Returns the query string if the page is accessed via a query string


Returns the Accept header from the current request


Returns the Accept_Charset header from the current request (such as utf-8,ISO-8859-1)


Returns the Host header from the current request


Returns the complete URL of the page from which the current page was called


Is the script queried through a secure HTTP protocol


Returns the IP address from where the user is viewing the current page


Returns the Host name from where the user is viewing the current page


Returns the port being used on the user's machine to communicate with the web server


Returns the absolute pathname of the currently executing script


Returns the value given to the SERVER_ADMIN directive in the web server configuration file


Returns the port on the server machine being used by the web server for communication


Returns the server version and virtual host name which are added to server-generated pages


Returns the file system based path to the current script


Returns the path of the current script


Returns the URI of the current page

*NOTE : "This study material is collected from multiple sources to make a quick refresh course available to students."

This website uses cookies to improve user experience. By using our website you consent to all cookies in accordance with our Cookie Policy. More info. I Agree