Computer Programming 9 - 4th QTR Reviewer

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/29

flashcard set

Earn XP

Description and Tags

Coverage: Page 9 - 48 (PHP module) (GLHF in your exams!)

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

30 Terms

1
New cards
<p>What is PHP Syntax?</p>

What is PHP Syntax?

It is defined as the structure of statements in a computer language.

2
New cards

What is the element “?>”

It is used to end the script.

3
New cards

(True or False) In a PHP, is everything in a statement a PHP command?

False. Not every word or token in a statement is a PHP command. Additionally, a PHP file may contain PHP script(s), HTML documents, or HTML elements.

4
New cards

It’s used to display a text or value of a variable.

Echo.

5
New cards

What is a single-line comment?

It generally starts with “//”. It’s a one-line explanation or note.

6
New cards

How do you usually create, save, and execute a PHP file?

Firstly, start a server (for instance, wampserver64). Then, open a text editor program and make a PHP script (notepad++). Thirdly, Save the PHP script and lastly, the file must be saved in the server (c: → wamp64 → www.).

7
New cards

What is a PHP variable?

It’s a variable used as a container for storing data. You can assign the value, change the value, or manipulate the value.

8
New cards

(True or False) Variable names should start with a number first before the letter.

False. The program will not work operationally because the variable “$1num” may cause the website to error or not work properly.

9
New cards

How many rules exactly are there in naming a variable.

There are 5 rules in naming a variable respectively.

10
New cards

What is an assignment operator?

It is used to assign a value to a variable.

11
New cards

What is a concatenation operator?

It is used to join two strings or values together.

12
New cards

What are the different classifications of PHP operators?

There are specifically 5 arithmetic operators in PHP. Namely, addition, subtraction, multiplication, division, and modulus or the percentage.

13
New cards

How do you implement and use the concatenation operator in a PHP structure? (Excluding HTML structure).

echo $a . $b;

14
New cards

(True or False) Does the $_POST function usually collect data and the values in the HTML form are shown on the URL or browser’s address bar?

False. It’s the $_GET function.

15
New cards

How does the $_POST function works? (Excluding HTML structure).

<form action = ‘sampleform.php’ method = ‘post’>

16
New cards

What is the condition statement?

It uses an expression answerable by yes/no or true or false.

17
New cards

What is a logical operator?

A logical operator connects conditions and returns true or false based on their combined truth values.

18
New cards

(True or False) Is equal operator “==“ and “=“ similar to one another?

False. When we refer to the variable “=“, it’s an assignment operator which is used to assign a value to a variable. Meanwhile, the equality operator “==“ compares two values to check if they are equal (as shown in the illustration).

<p><strong>False. </strong>When we refer to the variable “=“, it’s an <strong>assignment operator</strong> which is used to <strong>assign</strong> a value to a variable. Meanwhile, the <strong>equality operator</strong> “==“ <strong>compares two values</strong> to check if they are equal (as shown in the illustration).</p>
19
New cards

How many condition statements are there in PHP?

There are 4 types, respectively, if statement, if…else statement, if…else…if statement, and switch statement (not often used).

20
New cards

What are the contents of an if statement? (Excluding HTML structure)

if (condition)

{

codes to be executed once the condition is true;

}

21
New cards

What are the contents of an if…else…if statement? (Excluding HTML structure)

if (condition1)

{

codes to be executed once the condition1 is true;

}

else if (condition2)

{

codes to be executed once the condition2 is true;

}

else

{

codes to be executed once all the conditions are false;

}

22
New cards

What are the contents of an if…else statement? (Excluding HTML structure)

if (condition)

{

codes to be executed once the condition is true;

}

else

{

codes to be executed once the condition is false;

}

23
New cards

What are the contents of an switch case statement? (Excluding HTML structure)

Switch (condition)

{

case value1:

// codes to be executed if the case value1 meets the condition;

break;

case value2:

// codes to be executed if the case value2 meets the condition;

break;

default:

// codes to be executed if no case value meet the condition;

}

24
New cards

It’s a control structure that executes a statement or block of codes several times depending on the given condition statement.

Loop. It uses either comparison or logical operators to control the number of repetitions (FOR, WHILE, and DO WHILE).

25
New cards

What are the contents of a FOR loop?

for (initialize; condition; increment)

{
// codes to be executed;

// this part is called the loop body;

}

26
New cards

(True or False) If the word “Philippine School Doha” is repeated 12 times, is this execution correct? “for ($x = 1; $x <= 12.1; $x = $x + 1)

{

echo “Philippine School Doha“;

echo “<br>”;

}

False. Because the “condition” statement (12.1) is inputted incorrectly. Causing the website to malfunction once it’s executed.

27
New cards

What is the purpose of the while loop?

It repeatedly executes code as long as the given condition remains true.

28
New cards

What is the purpose of the for loop?

It’s coded a set number of times, based on initialization, condition, and increment.

29
New cards

What is the purpose of the do while loop?

It runs code at least once, then repeats it while the condition remains true.

30
New cards

Make a program that will input any number x and display all numbers from -x to x.

HTML (The bolded texts are the variables/elements that are replaceable)

<!DOCTYPE HTML>

<html>

<head>

<title>Sample.html</title>
</head>

<body>

<form action = ‘Sample.php’ method = ‘post’>

<input type= ‘text’ name = ‘num1’ placeholder = ‘number displayer’>

<input type = ‘submit’ value = ‘Compute’>

</form>

</body>

</html>

PHP

<!DOCTYPE HTML>

<html>

<head>

<title>Sample.php</title>
</head>

<body>

<?php

$x = $_POST [‘num1‘];

while ($x <= 10)

{

echo $x;

echo “<br>”;

$x = $x + 1;

}

?>

</body>

</html>