register_long_arrays

Its a flag and if its value is set to one we must use the longer version of the variable

Array Name Longer version of the name
$_POST $HTTP_POST_VARS
$_FILES $HTTP_POST_FILES
$_GET $HTTP_GET_VARS
$_COOKIE $HTTP_COOKIE_VARS
$_ENV $HTTP_ENV_VARS
$_SERVER $HTTP_SERVER_VARS
$_SESSION $HTTP_SESSION_VARS

Its not at all a convenient option , so its always better to have the value set to off

Unicode

Unicode is a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world’s writing systems. Developed in conjunction with the Universal Character Set standard and published in book form as The Unicode Standard, the latest version of Unicode consists of a repertoire of more than 109,000 characters covering 93 scripts, a set of code charts for visual reference, an encoding methodology and set of standard character encodings, an enumeration of character properties such as upper and lower case, a set of reference data computer files, and a number of related items, such as character properties, rules for normalization, decomposition, collation, rendering, and bidirectional display order

Unicode can be implemented by different character encodings. The most commonly used encodings are UTF-8, the now-obsolete UCS-2, and UTF-16. UTF-8 uses one byte for any ASCII characters, which have the same code values in both UTF-8 and ASCII encoding, and up to four bytes for other characters. UCS-2 uses two bytes for each character but cannot encode every character in the current Unicode standard. UTF-16 extends UCS-2, using four bytes to handle each of the additional characters.

Namespaces

Namespaces is a method with which we can group variable,function or objects so that we can have more than one variable or function or object with same name .

Namespaces were introduced into PHP from version 5.3 onwards

Use

• Helps to prevent accidentally re-defining functions, classes, constants, …
• Avoids having to use long, highly descriptive class names
• Constants, classes, traits, interfaces and functions are affeced by the use of namespaces
• Create sub-namespaces to sub-divide a library

Declaring Namespaces

• Must declare the use of namespaces with the keyword “namespace” at the beginning of the code file (right after <?PHP)
• Use one namespace per code file (best practice)
• Unless a namespace is defined, constants, classes, functions, traits and interfaces are defined with the global namespace
• Within a namespace qualifying with a “\” references the global namespace
• Once code elements within a single namespace are defined, they can be used in other php files

Example

<?php
 namespace php;
 class php
 {
 public function phpcodez()
 {
 echo 'Function1 <br />';
 }
 }
 namespace codez;
 class codez
 {
 public function phpcodez()
 {
 echo 'Function2 <br />';
 }
 }

$phpcodez = new phpphp();
 $phpcodez->phpcodez();

$phpcodez = new codezcodez();
 $phpcodez->phpcodez();

?>

Function

A function is a group of statements that will do certain tasks.

Why Function

When we develop a module in a project , we may need to implement certain tasks(block of statements ) more than once . Writing same block of codes more than once is not at all a good practice . Instead we can give a name to that block and can use them whenever necessary . When we define a block with a name , it is known as function .

• Blocks of code that execute in isolation (and local scope) that perform an action
• Function names are case-insensitive; defined in global scope
• Can be referenced before being defined unless function conditional
• Types: built-in (php supplied); user-defined; externally provided

General Format

function funation_name(){
echo “Error”; // can be on or more lines of statements
}

function – a keyword
funation_name – Any desired name(Should be meaningful)

Once the function is desfined , You can can invoke it by calling its name

<?php funation_name(); ?> // It will print the text “ Error”

A function can have arguments . When a fuction is define using arguments in it , we should pass the values when calling the it .

Example :
function function_sum($a,$b){
echo $a+$b;

}
<?php function_sum(7,8); ?> // It will display 15 as the result .

Note : We should not use any Builtin function name as the function name

PHP functions

A function is a group of statements that can be executed any time you want.

PHP has a number of predefine functions for you to use.

Below given are the different type of funtions available in PHP

register_globals

It can be considered as a flag that controls how you access form, server, and environment variables. By default this variable is set to Off, requiring you to use special arrays to access these variables. Its values are set in php.ini file .When the value is set to “on” , PHP will dynamically create global variable for many server variable as well as the query string parameters .

Its always better to set the value as “off”