Sai Gopal Wordpress Blog

saigopal wordpress blog

Saigopal's website

Saigopal's website

My Daughter Website

Weebly

Palwow

Freelance Jobs

Thursday, May 27, 2010

Appendix -b Beginning PHP5 ,APACHE,MYSQL WEBDEVELOPMENT PDF

B
PHP Quick Reference
This appendix lists some quick reference notes for your use. Consider the information in this
appendix to be your “cheat sheet.” These topics are covered in depth in Chapter 2.
PHP Syntax
The basic PHP syntax is as follows:

Displaying to Browser
To display text in a browser, use the following syntax:
”; //echo HTML text
?>
Assigning a Value to a Variable
To set a value to a variable, use the following syntax:

Passing Variables
You can pass variables among pages in your Web site in three ways: through a URL, through sessions,
and through a form.
Through a URL
To pass a variable through a URL, use the following HTML code:

Through Sessions
To pass a variable through a session, use the following PHP code:


Through a Form
A form must reference the PHP script that will parse the variables:

if Statements
To use if statements, type the following syntax:

or

704
Appendix B
else Statements
To use else statements, type the following syntax:

or
else {
//execute command 1;
//execute command 2;
//execute command 3;
}
?>
Nested if Statements
You can use nested if statements by using the following syntax:

Including a File
To include a file, use the following syntax:

Using Functions
You can create and call functions using the following syntax:

705
PHP Quick Reference
Arrays
You can set the values for an array in one of two ways:
”Albert”, “lastname”=>”Einstein”, “age”=”124”);
echo $name[“firstname”];
?>
or

If no keys are required, you can set the values for an array like this:

for
You can execute a block of code a specified number of times with the following for statement:
”;
}
foreach
You can apply the same block of code to each value in a specified array with the foreach statement:
foreach ($arrayvalue as $currentvalue) {
//these lines will execute as long as there is a value in $arrayvalue
echo $currentvalue;
echo “
\n”;
}
706

No comments: