NEW
Font size
S
M
L
XL
WorksheetsTLE 10 - Q3 Computer Programming
Total questions: 60
Worksheet time: 30mins
Name
Class
Date
1.
What does PHP stand for?
a)
a. PHP: Hypertext Preprocessor
b)
b. Private Home Page
c)
c. Personal Hypertext Processor
d)
d. Philippine Hypertext Preprocessor
2.
Which of the following is the correct opening and close tag for PHP scripts?
echo “This is PHP”;
a)
a.
b)
b.
c)
c. echo “This is PHP”;
d)
d.
3.
What is the correct way to end a PHP statement?
a)
a. .
b)
b. ;
c)
c. New line
d)
d. :
4.
The PHP syntax is most similar to:
a)
a. Perl and C
b)
b. JavaScript
c)
c. VBScript
d)
d. C# and Phyton
5.
How do you get information from a form that is submitted using the "get" method?
a)
a. Request.Form;
b)
b. $_GET[];
c)
c. Request.QueryString;
d)
d. $_POST[];
6.
With PHP, can we use both single quotes ( ' ' ) and double quotes ( " " ) for strings?
a)
a. No, we can't use both single quotes ( ' ' ) and double quotes ( " " ) for strings.
b)
b. Yes, we can use both single quotes ( ' ' ) and double quotes ( " " ) for strings.
c)
c. we can only use single quotes ( ' ' ) but we can't use double quotes ( " " ) for strings.
d)
d. we can only use double quotes ( " " ) but we can't use single quotes ( ' ' ) for strings.
7.
What is the correct way to create a function in PHP?
a)
a. create myFunction()
b)
b. new_function myFunction()
c)
c. function myFunction()
d)
d. function create myFunction()
8.
Which superglobal variable holds information about headers, paths, and script locations?
a)
a. $_GET
b)
b. $_SERVER
c)
c. $_SESSION
d)
d. $_POST
9.
Which one of these variables has an illegal name?
a)
a. $my_Var
b)
b. $my+Var
c)
c. $myVar
d)
d. $MyVar
10.
What is the purpose of the isset() function in PHP?
a)
a. To convert a variable to an integer
b)
b. To determine if a variable has been set
c)
c. To print a variable to the screen
d)
d. To destroy the session
11.
Which of the following is the correct Single-line comments in PHP?
a)
a. \\ This is a single-line comment
b)
b. / This is a single-line comment /
c)
c. \ This is a single-line comment \
d)
d. // This is a single-line comment
12.
How do you create a variable named txtSection and assign a value “ICT Computer Programming”?
a)
a. txtSection = “ICT Computer Programming
b)
b. $txtSection = “ICT Computer Programming
c)
c. txtSection = $“ICT Computer Programming
d)
d. $txtSection = $“ICT Computer Programming
13.
Which of the following is the correct PHP code to get the length of the string “Welcome to MNHS”;
a)
a. echo stleng(“Welcome to MNHS”)
b)
b. echo strlen(“Welcome to MNHS”)
c)
c. echo string(“Welcome to MNHS”)
d)
d. echo slen(“Welcome to MNHS”)
14.
How do you reverse the string “Programming” in PHP?
a)
a. echo strrev("Programming ");
b)
b. echo revstr("Programming ");
c)
c. echo srevert("Programming ");
d)
d. echo strevert("Programming ");
15.
Which of the following is the correct PHP code to replace the word “Programming” with the word “Systems Servicing”?
$oldtxt = "Welcome to Computer Programming”
a)
a. $newtxt = replace_str(“Programming”, “Systems Servicing”, $oldtxt);
b)
b. $newtxt = str_replace( “Systems Servicing”, “Programming”, $oldtxt);
c)
c. $newtxt = str_replace(“Programming”, “Systems Servicing”, $oldtxt);
d)
d. $oldxt = str_replace( “Systems Servicing”, “Programming”, $newtxt);
16.
Which of the following is the correct comparison operator to check if $num1 is NOT equal to $num2?
a)
a. var_dump($num1 NOT $num2);
b)
b. var_dump($num1 !! $num2);
c)
c. var_dump($num1 == $num2);
d)
d. var_dump($num1 != $num2);
17.
Which of the following is the correct comparison operator to check if $a equals $b.
a)
a. var_dump($a Equal $b);
b)
b. var_dump($a !! $b);
c)
c. var_dump($a == $b);
d)
d. var_dump($a != $b);
18.
How do you create a switch statement that will output "Hello" if $color is "red", and "welcome" if $color is "green"?
______________ {
case "red":
echo "Hello";
break;
case "green":
echo "Welcome";
break;
}
a)
a. switch ($color)
b)
b. $color switch
c)
c. $switch($color)
d)
d. switch color
19.
Which of the following is the correct PHP code to Output $i as long as $i is less than 6?
a)
a. $i = 1; while ($i > 6) { echo $i; $i++; }
b)
b. $i = 1; while ($i < 6) { echo $i; $i++; }
c)
c. $i = 1; while ($i = 6) { echo $i; $i++; }
d)
d. $i = 1; while ($i != 6) { echo $i; $i++; }
20.
How do you create a loop that runs from 0 to 9?
a)
a. for ($i = 0; $i < 10; $i++) { echo $i; }
b)
b. for ($i = 0; $i > 10; $i++) { echo $i; }
c)
c. for ($i = 0; $i = 10; $i++) { echo $i; }
d)
d. for ($i = 0; $i != 10; $i++) { echo $i; }
21.
How do you create a function named CalculateNumber?
a)
a. $function CalculateNumber
b)
b. $function $CalculateNumber
c)
c. function CalculateNumber()
d)
d. function CalculateNumber
22.
Inside a function with two paramenters, how do you print the first parameter?
a)
a. function myFunction($fname, $lname) { echo $fname; }
b)
b. function myFunction($fname, $lname) { echo $lname; }
c)
c. function myFunction($fname, $lname) { echo $first; }
d)
d. function myFunction($fname, $lname) { echo $parameter; }
23.
If the form gets submitted, how can you, in welcome.php, output the value from the "first name" field?
a)
a. Welcome
b)
b. Welcome
c)
c. Welcome
d)
d. Welcome
24.
How do you use the correct format parameter to output a date like this: 2023.02.17. ?
a)
a. echo date(“m.d.y”);
b)
b. echo date(“yyy.mmm.ddd”);
c)
c. echo date(“YYYY.mmm.dddd”);
d)
d. echo date(“Y.m.d”);
25.
What is MySQL?
a)
All the options are correct
b)
Cross-platform, open-source and free
c)
A relational database management system
d)
Developed, distributed, and supported by Oracle Corporation
26.
Which MySQL statement is used to select data from a database?
a)
EXTRACT
b)
SELECT
c)
OPEN
d)
GET
27.
With MySQL, how can you remove the records where the "username" is "admin" in the tbl_users table?
a)
a. DELETE username='admin' FROM tbl_users;
b)
b. DELETE ROW username='admin' FROM tbl_users;
c)
c. DELETE FROM tbl_users WHERE username = 'admin';
d)
d. REMOVE FROM tbl_users WHERE username = 'admin';
28.
How can you change the admin username default password to "Pass123" in the "password" column in the tbl_users table?
a)
a. UPDATE tbl_users SET password='Pass123' WHERE username = 'admin';
b)
b. MODIFY tbl_users SET password='Pass123' WHERE username='admin';
c)
c. UPDATE tbl_users SET username='Pass123' WHERE password = 'admin';
d)
d. MODIFY tbl_users SET username='Pass123' WHERE password='admin';
29.
With MySQL, how do you select all the records from a table named "tbl_users" where the "Username" is "admin" and the "password" is "pass123"?
a)
a. SELECT username='admin', password='pass123' FROM tbl_user;
b)
b. SELECT username='admin123', password='pass' FROM tbl_users;
c)
c. SELECT * WHERE username='admin' AND LastName='pass123' FROM tbl_users;
d)
d. SELECT * FROM tbl_users WHERE username='admin' AND LastName='pass123';
30.
With MySQL, how do you select all the columns from a table named "tbl_users"?
a)
SELECT *.tbl_users
b)
SELECT [all] FROM tbl_users
c)
SELECT * FROM tbl_users
d)
SELECT tbl_users
31.
What is Google Sites?
a)
a) A website builder offered by Google
b)
b) A social media platform
c)
c) A search engine
d)
d) An email service
32.
What types of content can be added to a website created on Google Sites?
a)
a) Text and images only
b)
b) Videos and PDFs only
c)
c) Google Docs, Google Sheets, and Google Slides only
d)
d) Text, images, videos, PDFs, Google Docs, and Google Sheets
33.
What is the web address for accessing Google Sites?
a)
a) sites.google.com
b)
b) google.com/site
c)
c) sites.com/google
d)
d) google.sites.com
34.
How many collaborators can work on a Google Sites website?
a)
A) Up to 5
b)
B) Up to 10
c)
C) Unlimited
d)
D) Only the website owner can make changes
35.
What is the purpose of the Page Editor tool in Google Sites?
a)
a) To create navigation menus for the website.
b)
b) To add text, images, videos, and other elements to website pages.
c)
c) To view website traffic data and insights.
d)
d) To share and collaborate with others on the website.
36.
What is the Drag-and-Drop Interface in Google Sites?
a)
a) A feature that allows users to move website elements around by typing in coordinates.
b)
b) A tool that automatically arranges website elements in an aesthetically pleasing way.
c)
c) A feature that allows users to easily move and resize website elements by clicking and dragging them.
d)
d) A tool that optimizes the website for viewing on mobile devices.
37.
What is the Navigation Menu in Google Sites?
a)
a) A feature that allows users to add text, images, videos, and other elements to website pages.
b)
b) A tool that optimizes the website for search engines.
c)
c) A feature that allows users to easily move and resize website elements by clicking and dragging them.
d)
d) A feature that allows users to create a menu to help visitors navigate their website.
38.
What is the benefit of using Google Sites for sharing and collaboration on website projects?
a)
A) It limits the number of collaborators to prevent errors
b)
B) It only allows read-only access to collaborators
c)
C) It allows for real-time collaboration and editing
d)
D) It requires a separate subscription for each collaborator
39.
What is the benefit of granting editing rights to specific users in Google Sites?
a)
a) It makes the website load faster
b)
b) It allows users to work together on a website and make changes collaboratively
c)
c) It increases the website's visibility on search engines
d)
d) It improves the website's security
40.
How does Google Sites integrate with Google Drive?
a)
a) Users can save their website designs directly to Google Drive
b)
b) Users can only upload files from Google Drive to their website
c)
c) Users can easily embed documents, spreadsheets, and presentations from their Google Drive into their website
d)
d) There is no integration between Google Sites and Google Drive
41.
How does Google Sites ensure that websites created on it are optimized for mobile devices?
a)
a) By providing mobile-specific layouts
b)
b) By automatically resizing content for mobile devices
c)
c) By using a mobile-responsive design
d)
d) By creating a separate mobile version of the website
42.
What type of account do you need to create a Google Sites website?
a)
a) A Google Cloud account
b)
b) A Google Ads account
c)
c) A Google Analytics account
d)
d) A Gmail account
43.
What types of websites can you create with Google Sites?
a)
a) Personal websites
b)
b) Business websites
c)
c) Educational websites
d)
d) Personal, Business, and Educational websites
44.
What is the name of the feature in Google Sites that allows you to create a form for collecting information from visitors?
a)
a) Google Forms
b)
b) Google Surveys
c)
c) Google Polls
d)
d) Google Feedback
45.
How can users access Google Sites?
a)
a) By creating an account on Google Sites
b)
b) By signing in with their Facebook account
c)
c) By going to sites.google.com and signing in with their Google account
d)
d) By downloading a mobile app
46.
Is a Facebook account required to use Google Sites?
a)
A) Yes, Google Sites can only be accessed through a Facebook account.
b)
B) No, Google Sites is a separate website builder offered by Google.
c)
C) A Facebook account is only required for business websites.
d)
D) A Facebook account is only required for personal websites.
47.
Can users customize the look and feel of their Google Sites website?
a)
A) No, Google Sites has a set design and cannot be customized.
b)
B) Yes, Google Sites provides users with customization options such as changing the color scheme and font style.
c)
C) Customization options are only available for paid Google Workspace accounts.
d)
D) Only web design professionals can customize a Google Sites website.
48.
Do Google Sites require a subscription?
a)
A) Yes, a paid subscription is required to use Google Sites.
b)
B) No, Google Sites is a free website builder.
c)
C) A subscription is only required for business websites, not personal websites.
d)
D) A subscription is required for mobile-responsive design.
49.
Can users add social media links to their Google Sites website?
a)
A) No, Google Sites does not allow for social media integration.
b)
B) Yes, users can add social media icons and link them to their respective profiles.
c)
C) Only paid Google Workspace accounts allow for social media integration.
d)
D) Social media links can only be added to personal websites, not business websites.
50.
Is coding or web design experience required to use Google Sites?
a)
A) Yes, advanced coding and web design skills are required.
b)
B) No, Google Sites does not require any coding or web design experience.
c)
C) Some basic coding knowledge is necessary to use Google Sites.
d)
D) Only web design experience is necessary to use Google Sites.
51.
What is CRUD in the context of web applications?
a)
A. A programming language used for web development
b)
B. A database management system used for web applications
c)
C. An architectural pattern used for designing web applications
d)
D. An acronym that stands for Create, Read, Update, Delete.
52.
Which of the following is the correct syntax for using the move_uploaded_file() function to move an uploaded profile picture to a new location?
a)
a. move_uploaded_file($_FILES["profile_picture"]["tmp_name"], $target_file)
b)
b. move_uploaded_file($_FILE["profile_picture"]["temp_name"], $target_files)
c)
c. move_uploaded_file($_FILES["profile_picture"]["temp.name"], $target_file)
d)
d. move_uploaded_file($_FILE["profile_picture"]["tmp.name"], $target_file)
53.
Which of the following SQL statements is correct for changing the profile picture of a user in a database table named tbl_users?
a)
A. $sql = "UPDATE tbl_users SET profile_pic='$profile_pic' WHERE userid='$userid'";
b)
B. $sql = "SELECT profile_pic FROM tbl_users WHERE userid='$userid'";
c)
C. $sql = "DELETE FROM tbl_users WHERE profile_pic='$profile_pic' AND userid='$userid'";
d)
D. $sql = "INSERT INTO tbl_users (profile_pic) VALUES ('$profile_pic') WHERE userid='$userid'";
54.
Which of the following is TRUE about the "dbconnect.php" file used for database connectivity in PHP?
a)
A. It is a built-in PHP function used to connect to a database.
b)
B. It contains database credentials such as the host, username, password, and database name.
c)
C. It is not required to establish a connection to a database in PHP.
d)
D. It is only used for connecting to MySQL databases.
55.
Which of the following is the correct SQL statement for changing a user's password in changepass.php?
a)
a. $sql = "DELETE FROM tbl_users WHERE password='$newpass' AND username='$username'";
b)
b. $sql = "SELECT password FROM tbl_users WHERE username='$username'";
c)
c. $sql = "UPDATE tbl_users SET password='$newpass' WHERE username='$username'";
d)
d. $sql = "INSERT INTO tbl_users (password) VALUES ('$newpass') WHERE username='$username'";
56.
What does the following PHP code do in home.php?
a)
a. Starts a new session for the user
b)
b. Checks if the user is logged in, and redirects to the login page if they are not
c)
c. Sets a session variable for the user's login status
d)
d. Destroys the user's session and logs them out
57.
What does the following PHP code do in logout.php?
a)
A. Starts a new session for the user
b)
B. Checks if the user is logged in, and redirects to the login page if they are not
c)
C. Logs the user out by destroying their session and redirecting them to the login page
d)
D. Sets a session variable for the user's login status
58.
Which of the following statements is TRUE about the PHP code in register.php shown below?
query($sql) === TRUE) {
header("location: regSuccess.php");
} else {
echo "Error: " . $sql . "
" . $conn->error; } // Close the MySQL connection $conn->close(); ?>
" . $conn->error; } // Close the MySQL connection $conn->close(); ?>
a)
A. It inserts data into the "tbl_users" table based on user input.
b)
B. It updates data in the "tbl_users" table based on user input.
c)
C. It retrieves data from the "tbl_users" table and displays it to the user.
d)
D. It deletes data from the "tbl_users" table based on user input.
59.
What is the purpose of the following code in verify.php shown below?
a)
A. It checks if the client browser used the GET method to request the current page.
b)
B. It checks if the client browser used the POST method to submit a form on the current page.
c)
C. It retrieves data from the server using the POST method.
d)
D. It retrieves data from the server using the GET method.
60.
What is the purpose of the following code in PHP?
query($sql);
if ($result->num_rows == 1) {
// Login successful, store session variables and redirect to dashboard
$_SESSION['loggedin'] = true;
$_SESSION['username'] = $username;
while ($row = mysqli_fetch_array($result)) {
$userid = $row['userid'];
header("location: home.php?userid=$userid");
}
} else {
// Login failed, display error message
echo "* Invalid username or password. Please try again.";
}
$conn->close
?>
a)
A. It updates a user's login credentials in the database.
b)
B. It retrieves data from the server using the POST method.
c)
C. It creates a new user in the database.
d)
D. It authenticates user login credentials and redirects to a dashboard (home.php) page.
Reset
