preview

Computerized Enrollment System Php Codes

Decent Essays

PHP
What You Should Already Know
Before you continue you should have a basic understanding of the following: * HTML/XHTML * JavaScript
If you want to study these subjects first, find the tutorials on our Home page.

What is PHP? * PHP stands for PHP: Hypertext Preprocessor * PHP is a server-side scripting language, like ASP * PHP scripts are executed on the server * PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) * PHP is an open source software * PHP is free to download and use

What is a PHP File? * PHP files can contain text, HTML tags and scripts * PHP files are returned to the browser as plain HTML * PHP files have a file extension of ".php", …show more content…

PHP has four different variable scopes: * local * global * static * parameter

Local Scope
A variable declared within a PHP function is local and can only be accessed within that function. (the variable has local scope):
<?php
$a = 5; // global scope

function myTest()
{
echo $a; // local scope
}

myTest();
?>
The script above will not produce any output because the echo statement refers to the local scope variable $a, which has not been assigned a value within this scope.
You can have local variables with the same name in different functions, because local variables are only recognized by the function in which they are declared.
Local variables are deleted as soon as the function is completed.

Global Scope
Global scope refers to any variable that is defined outside of any function.
Global variables can be accessed from any part of the script that is not inside a function.
To access a global variable from within a function, use the global keyword:
<?php
$a = 5;
$b = 10;

function myTest()
{
global $a, $b;
$b = $a + $b;
}

myTest(); echo $b;
?>
The script above will output 15.
PHP also stores all global variables in an array called $GLOBALS[index]. Its index is the name of the variable. This array is also accessible from within functions and can be used to update global variables directly.
The example above can be rewritten as this:
<?php
$a = 5;
$b = 10;

Get Access