Finals Lecture 1: PHP Flashcards

1
Q

In PHP, GET and POST are two different methods used to…

A

send data from a form to a server.

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

Data is appended to the URL.

A

GET Method

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

Limited amount of data can be sent because it is included in the URL.

A

GET Method

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

Data is visible to everyone in the URL, including the user.

A

GET Method

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

Not suitable for sensitive data.

A

GET Method

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

Example of a form using the GET method in HTML:

In this example, if the user enters “john” into the text field and submits the form, the URL may look like this: process.php?username=john

A

<form>
<input></input>
<input></input>
</form>

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

In PHP, you can access the data sent via GET using the…

A

$_GET superglobal array;

For example:
$username = $_GET[‘username’];

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

Data is included in the body of the HTTP request.

A

POST Method

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

Can send larger amounts of data.

A

POST Method

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

Data is not visible in the URL.

A

POST Method

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

Suitable for sensitive data.

A

POST Method

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

Example of a form using the POST method in HTML:

A

<form>
<input></input>
<input></input>
</form>

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

In PHP, you can access the data sent via POST using the…

A

$_POST superglobal array;

For example:
$username = $_POST[‘username’];

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

In many cases, the choice between GET and POST depends on the…

A

nature of the data being transmitted.

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

Use GET when you are ___, and use POST when you are ___ or ___.

A

retrieving data from the server; sending sensitive information; making changes on the server

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

In PHP, the ___ is used to check if a variable is set and is not null. It returns true if the variable exists and has a value other than null; otherwise, it returns false.

A

isset() function;

if (isset($name))

17
Q

This function is commonly used to prevent errors that might occur if you try to use a variable that hasn’t been defined or initialized.

A

isset() function;

if (isset($name))

18
Q

Here’s a basic example of using isset() function:

A

php
Copy code
// Check if the variable $name is set
if (isset($name)) {
echo “The variable $name is set and not null.”;
} else {
echo “The variable $name is either not set or null.”;
}