This document discusses PHP include statements and code reuse. It provides examples of including PHP files using include and include statements. It also discusses how included files are treated as PHP code and executed.
ENG / MohamedSaad pamicloud.com
Include Statement
Code Reuse
Require Statement
Case Study
2.
Include PHP Statement
Includestatement are used to include
the contents of one PHP file within
another PHP file.
Contents are treated as PHP Code.
Include Statement Syntax
Include ‘header.php’
Include (‘header.php’);
Can notinclude any file at all…!?
The behavior of these functions is affected by
settings in php.ini.
allow_url_fopen "1"
allow_url_include "0"
10.
Can notinclude any file at all…!?
The behavior of these functions is affected by
settings in php.ini.
ini_set("allow_url_fopen", "On");
php_value allow_url_fopen On
11.
Sets the valueof the given configuration option.
The configuration option will keep this new value
during the script's execution, and will be restored
at the script's ending.
<?php
echo ini_get('display_errors');
if (!ini_get('display_errors')) {
ini_set('display_errors', '1');
}
echo ini_get('display_errors');
?>
ini_get() - Gets the value
of a configuration option.
12.
Sets the valueof the given configuration option.
The configuration option will keep this new value
during the script's execution, and will be restored
at the script's ending.
<?php
echo ini_get('display_errors');
if (!ini_get('display_errors')) {
ini_set('display_errors', '1');
}
echo ini_get('display_errors');
?>
ini_get() - Gets the value
of a configuration option.
URL have specificsyntax rules.
Only :
Uppercase & lowercase Characters.
Underscores.
Tildes
Hyphens
Decimal digits
Spaces should be removed
Pami Cloud-> Pami+Cloud
17.
Used inComparison Operator .
It`s mean true or false.
We already know
String.
Integer.
Float.
TRUE or false
Not case sensitive
All upper or all lower
18.
The specialdata type is used for variables
that have no data assigned to them.
A variable can be NULL if:
No value assigned to it.
The variable has been unset
$X == NULL
Correct syntax to Compare with NULL
19.
PHP aweak-typed language meaning it does
not require data type.
Value will determine variable data type.
Type juggling process or automatic type
conversion.
Juggling Process Called Type Casting
Php.ini directiveerror_reporting is used to set which type of
error PHP have to catch .
(predefined config constants)
E_ERROR(int)
Run time - Fatal error , can not be recovered.
E_WAENING
Run time – execution of the script is completed.
E_PARSE
Compile time – parse errors
23.
PHP providean error control operator @,
which is used to supress errors generated by
expressions.
It`s Un-array operator.
$php_errormsg variable stores last error
24.
Php.ini directiveerror_reporting is used to set
which type of error PHP have to catch .
(predefined config constants)
Register_globals isa configuration directive
that automatically creates global variables.
$_GET[‘name’] however if register_globals
was set to on php automatically create
variable with global scope called $name;
But it`s Deprecated from php since ver 5.3.0.
Equality: ==
in Equality :!=
Identity :===TRUE if have same Key/Value of the same
type
Not-identity :!==
The Union operator + used to append any mew key/value pairs in
the end of the array.
29.
Var varare variable that can be
defined dynamically with PHP scripts.
Example
$x=“user”
$$x = $user
__LINE__ :currentexe line number.
__FILE__ :absolute path to script being exe.
__DIR__ :absolute directory of script been
exe.
__FUNCTION__ :name of the function
currently exe.
33.
PHP Providethe exit() construct which
can used to terminate the execution of
a script.
Die() is just another name
34.
Location HTTPHeader:
header(“Location: http://cx.com”);
You must call header function before
any generated output