Академический Документы
Профессиональный Документы
Культура Документы
PHP
INTRODUCTION
Request File
File
Response Files Server
ECHO / PRINT
PHP echo statement can be used to print string, multi line strings,
escaping characters, variable, array etc.
Returns nothing.
Syntax : void echo ( string $arg1 [, string $... ] ) echo "Hello by PHP echo";
PHP print statement can be used to print string, multi line strings,
escaping characters, variable, array etc.
Returns 1.
Syntax: int print(string $arg) print "Hello by PHP print ";
VARIABLES
A variable is a temporary storage that is used to store data temporarily.
In PHP, a variable is declared using $ sign followed by variable name.
Syntax : $variablename=value;
Variable:
Variable: Rules Declaring string, integer
Variable names begin with a dollar sign ( $ ). and float
Eg : $str="hello";
PHP variables must start with letter or underscore only. $x=200;
PHP variable can't be start with numbers and special symbols $y=44.6;
The $var (single dollar) is a normal variable with the name var that stores any value
like string, integer, float, etc.
The $$var (double dollar) is a reference variable that stores the value of the
$variable inside it.
DATA TYPES
Scalar Types
boolean
integer
float
String
Compound Types
array
object
OPERATORS
Multi-Line Comments
/* Comments are here */
CONTROL STATEMENTS
Append to File :
fwrite(file_pointer, content) : to write content of the string into file.
Delete File :
unlink(file_name) : to delete file.
fclose(file_pointer) : close file
feof(file_pointer) : reach end of file
filesize(file_name) : size of file.
COOKIE
Cookies are a mechanism for storing data in the remote browser and thus tracking
or identifying return users.
A cookie can only be read from the domain that it has been issued from.
Cookie is created at server side and saved to client browser.
Each time when client sends request to the server, cookie is embedded with request.
1. Request
Delete Cookie :
Syntax : setcookie("CookieName", time()-3600);
DATABASE CONNECTIVITY
Connect to Database :
Syntax :mysqli_connect (server, username, password,database)
Create Table :
$sql = "create table student(id INT, name VARCHAR(20))”
Syntax :mysqli_query($conn, $sql) ;
Insert Record Table :
$sql = “insert into table values(1,”ABC”)”
Syntax :mysqli_query($conn, $sql) ;
DATABASE CONNECTIVITY