Click here to load reader
Upload
jacob-william
View
135
Download
0
Embed Size (px)
Citation preview
PHP Assignment Help
PHP Assignment Helphttp://www.myassignmenthelpers.com/[email protected]
What is PHP?PHP is a scripting language commonly used on web servers.Stands for PHP: Hypertext PreprocessorOpen sourceEmbedded codeComparable with ASPMultiple operating systems/web servers
PHPdeveloped in 1995 by Rasmus Lerdorf (member of the Apache Group)originally designed as a tool for tracking visitors at Lerdorf's Web sitewithin 2 years, widely used in conjunction with the Apache serverdeveloped into full-featured, scripting language for server-side programmingfree, open-sourceserver plug-ins exist for various serversnow fully integrated to work with mySQL databasesPHP is similar to JavaScript, only its a server-side languagePHP code is embedded in HTML using tagswhen a page request arrives, the server recognizes PHP content via the file extension (.php or .phtml)the server executes the PHP code, substitutes output into the HTML pagethe resulting page is then downloaded to the clientuser never sees the PHP code, only the output in the page
Why it is used?Dynamic generation of web-page contentDatabase interactionProcessing of user supplied dataEmailFile handlingText processingNetwork interaction
Hello World! PHP Test
Using your favoured text editor (e.g. Notepad) create the file on the slide
Save it in your web space as hello.php and navigate to the file via your web browser
You should seeHello World! On the page
If that has worked replace all with phpinfo(); and run again
You should now see a page with lots of information about the PHP installation this will become useful later!
NOT XHTML (NO DOCTYPE SETTING ETC) TO SAVE SPACE ON PAGE
Comments// This is a comment# This is also a comment/* This is a commentthat is spread overmultiple lines */Do not nest multi-line comments// recommended over #
Comments
Variables: Naming$ followed by variable nameCase sensitive$variable differs from $VariableStick to lower-case to be sure!Name must started with a letter or an underscoreFollowed by any number of letters, numbers and underscores
Variables: example
Demo the fact that the variable can be changed..
$name = Phil;$age = 23;$name = Ed;echo $name;echo is ;echo $age;// Ed is 23
ConstantsConstants (unchangeable variables) can also be defined.Each constant is given a name (note no preceding dollar is applied here).By convention, constant names are usually in UPPERCASE.
A constant is an identifier for a single valueCannot be changed during execution (or undefined)Same naming convention as a standard variable (just no $)Are global (can be accessed anywhere within functions, etc.)
There are many predefined constants (see www.php.net for the long list!)Core constantsSet in the PHP coreMostly to do with error tracking and also core items like version, install directories, etc.Standard constantsLoads more!Extension constantsThese are set by extensions if they are loadedSee individual extension descriptions for details
Constants
OperatorsArithmetic Operators: +, -, *,/ , %, ++, --Assignment Operators: =, +=, -=, *=, /=, %=
Comparison Operators: ==, !=, >, =,
PHP - Forms
Access to the HTTP POST and GET data is simple in PHP The global variables $_POST[] and $_GET[] contain the request data