0% found this document useful (0 votes)
71 views2 pages

Super Global Keyword in PHP: $GLOBALS ('Y')

This document discusses different types of variables in PHP including local variables accessible only inside functions, global variables accessible outside functions, and static variables. It also covers PHP superglobal variables like $_POST and $_SERVER which provide information about forms and server headers. The document provides steps for connecting a PHP script to a MySQL database including using mysql_connect() to establish the connection, mysql_select_db() to choose a database, mysql_query() to run queries, and mysql_close() to end the connection. It also mentions mysqli_real_escape_string() for securely transferring variables to the database.

Uploaded by

Ritesh Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views2 pages

Super Global Keyword in PHP: $GLOBALS ('Y')

This document discusses different types of variables in PHP including local variables accessible only inside functions, global variables accessible outside functions, and static variables. It also covers PHP superglobal variables like $_POST and $_SERVER which provide information about forms and server headers. The document provides steps for connecting a PHP script to a MySQL database including using mysql_connect() to establish the connection, mysql_select_db() to choose a database, mysql_query() to run queries, and mysql_close() to end the connection. It also mentions mysqli_real_escape_string() for securely transferring variables to the database.

Uploaded by

Ritesh Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

variables in PHP:

local :

global :outside the function.

static

inside a function.

NOTE: we can't access global variables inside a function.


if we want to access global variables inside the function we use the Global
keyword.

Super global keyword in PHP:


$GLOBALS['y']
var dump($x) // to give the datatype of the variable.

$_POST (php super global super variable)


It can bind the form data.

$_SERVER
gives info about header path and script location.
$_SERVER['PHP_SELF']
will return to itself,
$_SERVER['SERVER_NAM']
filter_var()
gives specific filter to the variable.
ex: filter_var('email',filter-validate,(optional)flag)
//checks if the email in the email textbox is a valid email

Steps for creating php with mysql:


1. Mysql_connect():for connecting php with mysql
parameters:
host_name: //localhost
username://root
password://password
$conn=mysql_connect(host_name,username,password)

2. selecting database:
mysql_select_db(database_name);
3. Mysql queries:
mysql_query(query);
4. closing a connection
mysql_close($conn)
5. mysqli_real_rescape_string(connection,escapestring);
securely transfers our variables to mysql database.

You might also like