PHP

Created by SeanMarkham 

Upgrade to
remove ads

73 terms

What does php stand for?

PHP stands for PHP: Hypertext Preprocessor

is PHP server side or client side scripting language?

server side

how are php files returned to the browser?

PHP files are returned to the browser as plain HTML

how is a php started and ended?

A PHP scripting block always starts with <?php and ends with ?>

where can a php script be placed in the document?

anywhere

how must each php code line end?

with a semi colon

what is the purpose of the semi colon?

it is a separator and used to distinguish one set of instructions from another

what are two basic statements to output text with PHP?

echo and print

what happens if the php file has an html extension instead of PHP?

the php code will not be executed

how is a single line comment made in php?

With //

how is a comment block made?

/ /

What are variables used for?

Variables are used for storing values, such as numbers, strings or function results, so that they can be used many times in a script.

what do all variables start with?

All variables in PHP start with a $ sign symbol.

The correct way of setting a variable in PHP:

$var_name = value;

is PHP strongly or loosely typed?

loosely

in php does a variable need to be declared (created) before being set?

no, php automatically creates the variable and sets it to the correct type.

What is meant by the term strongly typed?

variables have to be defined before they can be used

in php how must a variable name start?

A variable name must start with a letter or an underscore _

What kinds of characters can a variable name contain?

A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ )

should a variable name contain spaces?

no

if a variable name is more than one word how should it be formatted?

with an underscore between words or with the second word capitalized

What is a string variable used for?

A string variable is used to store and manipulate a piece of text.

What is the only string operator in php?

The concatenation operator (.)

What is the concatenation operator used for?

to put two string values together.

what are operators used for?

Operators are used to operate on values.

What kinds of different operators exist?

arithmetic, assignment, comparison, and logical

when should the if else statement be used?

if you want to execute a set of code when a condition is true and another if the condition is not true

when should the else if statement be used?

is used with the if...else statement to execute a set of code if one of several condition are true

if more than one line is to be executed as a result of the if else statement then the lines to be executed should be enclosed in curly braces

...

What is the switch statement used for in PHP?

to perform one of several different actions based on one of several different conditions.

If you want to select one of many blocks of code to be executed which statement should be used?

switch

What is the primary advantage of using the switch statement?

It avoids avoid long blocks of if..elseif..else code.

What is an Array?

An array can store one or more values in a single variable name.

What is the advantage of arrays?

Instead of having many similar variables, you can store the data as elements in an array.

how are elements in an array accessed?

Each element in the array has its own ID so that it can be easily accessed.

There are three different kinds of arrays?

Numeric, associative, and multidimensional

what is a numeric array?

A numeric array stores each element with a numeric ID key.

What are two different ways numeric array id's can be created?

Manually or automatically

What are associative arrays?

In An associative array, each ID key is associated with a value.

What is a multidimensional array?

In a multidimensional array, each element in the main array can also be an array. And each element in the sub-array can be an array, and so on.

What are looping statements used for?

Looping statements in PHP are used to execute the same block of code a specified number of times.

What are the looping statements in PHP?

while, do while , for and foreach

What does the while statement do?

loops through a block of code if and as long as a specified condition is true

What does the do..while statement do?

loops through a block of code once, and then repeats the loop as long as a special condition is true

What does the for statement do?

loops through a block of code a specified number of times

What does the foreach statement do?

loops through a block of code for each element in an array

Where does the real power in PHP come from?

From over 700 functions

What is a function?

A function is a block of code that can be executed whenever we need it.

how do all funtions in PHP start?

with the word function

how should a function be named?

so that you can understand what it does by it's name

where is the functions code located?

between the curly braces

how do you add more functionality to functions?

by adding parameters

what are parameters?

A parameter is just like a variable.

What is another way functions can be used?

to return values

what are the $_get and $_post variables used for?

The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.

What is the most important thing to notice when dealing with HTML forms and PHP?

any form element in an HTML page will automatically be available to your PHP scripts.

A good way to validate a form on the server

to post the form to itself, instead of jumping to a different page.

What is the advantage of validating a form on the server by posting to itself?

the user will then get the error messages on the same page as the form. This makes it easier to discover the error.

What is the the $_GET Variable

The $_GET variable is an array of variable names and values sent by the HTTP GET method. The $_GET variable is used to collect values from a form with method= get

What is another disadvantage of using the $_get variable?

since the information is transmitted and visible in the address bar is is not secure for personal data

What is the disadvantage of using the $_get variable?

the largest variable it can hold is 100 characters

What is the advantage of using the $_get variable?

the page can be bookmarked

what is the purpose of the $_REQUEST Variable?

The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.

What methods can the $_request variable be used with?

GET and POST

What is the the $_post Variable?

The $_POST variable is an array of variable names and values sent by the HTTP POST method. The $_POST variable is used to collect values from a form with method= post .

What are the advanteages to using $_POST

Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.

What is the PHP date() function used for?

The PHP date() function is used to format a time or a date.

What are server side includes?

Server Side Includes (SSI) are used to create functions, headers, footers, or elements that will be reused on multiple pages.

What do the include() or require() function allow you to do?

insert the content of a file into a PHP file before the server executes it

Why is the include() and require() function useful?

Because it can save a considerable amount of time by allowing you to change only a couple of files when headers,footers or menus have to be changed for a website instead of having to maually change all the pages.

How are the include() or require() function different?

The two functions are identical in every way, except how they handle errors

How does the include() or require() function handle errors?

The include() function generates a warning (but the script will continue execution) while the require() function generates a fatal error (and the script execution will stop after the error).

What is the purpose of the Expat parser?

makes it possible to process XML documents in PHP

Please allow access to your computer’s microphone to use Voice Recording.

Having trouble? Click here for help.

We can’t access your microphone!

Click the icon above to update your browser permissions above and try again

Example:

Reload the page to try again!

Reload

Press Cmd-0 to reset your zoom

Press Ctrl-0 to reset your zoom

It looks like your browser might be zoomed in or out. Your browser needs to be zoomed to a normal size to record audio.

Please upgrade Flash or install Chrome
to use Voice Recording.

For more help, see our troubleshooting page.

Your microphone is muted

For help fixing this issue, see this FAQ.

Star this term

You can study starred terms together

NEW! Voice Recording

Create Set