Lesson 1 (MIDTERM) Flashcards

(66 cards)

1
Q

is a special variable that can hold many values under a single name, and you can access the values by referring to an index number or index name.

A

Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

stores multiple values in one single variable.

A

Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Three ttypes of arrays

A

Indexed Arrays
Associative Arrays
Multidimensional Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Arrays with a numeric index

A

Indexed Arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Arrays with named keys

A

Associative Arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Arrays containing one or more arrays

A

Multidimensional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

its items can be of any data type.

A

Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The most common are strings and numbers (int, float), but ______ items can also be objects, functions or even arrays.

A

Arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

each item has an index number

A

Indexed Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

By default, the first item has index 0, the second item has item 1, etc.

A

Indexed Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

To access an array item, you can refer to the _____ _____.

A

index number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

To change the value of an array item, use the _____ _____

A

index number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

To loop through and print all the values of an indexed array, you could use a ________

A

foreach loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

are arrays that use named keys that you assign to them.

A

Associative Arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

To access an associative array item you can refer to the ______ ____

A

Key name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

To change the value of an associative array item, use the ____ _____.

A

Key name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

To loop through and print all the values of an associative array, you could use a ____ ____

A

foreach loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

were introduced in PHP 4.1.0, and are built-in variables that are
always available in all scopes.

A

SUPERGLOBALS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Some predefined variables in PHP are “superglobals”, which means that they are always accessible, regardless of scope - and you can access them from any function, class or file without having to do anything special.

A

SUPERGLOBALS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What are the superglobal variables

A

$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

is an array that contains all global variables.

A

$GLOBALS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

are variables that can be accessed from any scope.

A

Global Variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Variables of the outermost scope are automatically ____ _____, and can be used by any scope, e.g. inside a function.

A

Global Variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

To use a global variable inside a function you have to either define them as global with the global keyword, or refer to them by using the _______ syntax.

A

$GLOBALS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
is a PHP super global variable which holds information about headers, paths, and script locations.
$_SERVER
26
What are the PHP $_SERVER ELEMENTS
$_SERVER['PHP_SELF'] $_SERVER['GATEWAY_INTERFACE'] $_SERVER['SERVER_ADDR'] $_SERVER['SERVER_NAME'] $_SERVER['SERVER_SOFTWARE'] $_SERVER['SERVER_PROTOCOL'] $_SERVER['REQUEST_METHOD'] $_SERVER['REQUEST_TIME'] $_SERVER['QUERY_STRING'] $_SERVER['HTTP_ACCEPT'] $_SERVER['HTTP_ACCEPT_CHARSET'] $_SERVER['HTTP_HOST'] $_SERVER['HTTP_REFERER'] $_SERVER['HTTPS'] $_SERVER['REMOTE_ADDR'] $_SERVER['REMOTE_HOST'] $_SERVER['REMOTE_PORT'] $_SERVER['SERVER_ADMIN'] $_SERVER['SERVER_PORT'] $_SERVER['SERVER_SIGNATURE'] $_SERVER['PATH_TRANSLATED'] $_SERVER['SCRIPT_NAME'] $_SERVER['SCRIPT_URI']
27
Returns the filename of the currently executing script
$_SERVER['PHP_SELF']
28
Returns the version of the Common Gateway Interface (CGI) the server is using
$_SERVER['GATEWAY_INTERFACE']
29
Returns the IP address of the host server
$_SERVER['SERVER_ADDR']
30
Returns the name of the host server (such as www.w3schools.com)
$_SERVER['SERVER_NAME']
31
Returns the server identification string (such as Apache/2.2.24)
$_SERVER['SERVER_SOFTWARE']
32
Returns the name and revision of the information protocol (such as HTTP/1.1)
$_SERVER['SERVER_PROTOCOL']
33
Returns the request method used to access the page (such as POST)
$_SERVER['REQUEST_METHOD']
34
Returns the timestamp of the start of the request (such as 1377687496)
$_SERVER['REQUEST_TIME']
35
Returns the query string if the page is accessed via a query string
$_SERVER['QUERY_STRING']
36
Returns the Accept header from the current request
$_SERVER['HTTP_ACCEPT']
37
Returns the Accept_Charset header from the current request (such as utf-8,ISO-8859-1)
$_SERVER['HTTP_ACCEPT_CHARSET']
38
Returns the Host header from the current request
$_SERVER['HTTP_HOST']
39
Returns the complete URL of the current page (not reliable because not all user-agents support it)
$_SERVER['HTTP_REFERER']
40
Is the script queried through a secure HTTP protocol
$_SERVER['HTTPS']
41
Returns the IP address from where the user is viewing the current page
$_SERVER['REMOTE_ADDR']
42
Returns the Host name from where the user is viewing the current page
$_SERVER['REMOTE_HOST']
43
Returns the port being used on the user's machine to communicate with the web server
$_SERVER['REMOTE_PORT']
44
Returns the value given to the SERVER_ADMIN directive in the web server configuration file (if your script runs on a virtual host, it will be the value defined for that virtual host) (such as someone@w3schools.com)
$_SERVER['SERVER_ADMIN']
45
Returns the port on the server machine being used by the web server for communication (such as 80)
$_SERVER['SERVER_PORT']
46
Returns the server version and virtual host name which are added to server-generated pages
$_SERVER['SERVER_SIGNATURE']
47
Returns the file system based path to the current script
$_SERVER['PATH_TRANSLATED']
48
Returns the path of the current script
$_SERVER['SCRIPT_NAME']
49
Returns the URI of the current page
$_SERVER['SCRIPT_URI']
50
The PHP superglobals $_GET and $_POST are used to collect form-data.
PHP Form Handling
51
When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named "welcome.php". The form data is sent with the HTTP POST method.
PHP Form Handling
52
contains an array of variables received via the HTTP POST method.
$_POST
53
There are two main ways to send variables via the HTTP Post method:
HTML forms JavaScript HTTP requests (AJAX)
54
A query string is data added at the end of a URL. In the link below, everything after the ? sign is part of the query string:
$_GET
55
is a PHP super global variable which contains submitted form data, and all cookie data.
$_REQUEST
56
s an array containing data from $_GET, $_POST, and $_COOKIE.
$_REQUEST
57
requests are usually data submitted from an HTML form
POST
58
requests can be form submissions as in the example above, with the method attribute of the HTML
element set to GET.
GET
59
requests can also be data from a query string (information added after a URL address).
GET
60
refers to the process of ascertaining if the data entered by the user in various form elements is acceptable for further processing.
Form Validation
61
before its subsequent processing avoids possible exceptions and runtime errors.
Validation of data
62
can be done both on the client-side and on the server-side. When the client submits the form, the form data is intercepted by the PHP script running on the server. Using various functions available in PHP, the server-side form validation can be done.
Validation
63
Think ________when processing PHP forms
Security
64
The new input controls as per the HTML5 specifications have in-built validation. For example an input element of the type ‘email’, even though it is a text field, is customized to accept a string that is according to email address protocol.
PHP Form Validation (Client-Side)
65
takes place before the data is submitted to the server. The same thing is true with other input types such as URL, number, etc.
Validation
66
the server-side with PHP comes into picture, either when the form data passes the client-side validation, or there’s no validation on the client side at all.
Validation