Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 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