Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 32 pages
Exam (elaborations)

PHP Midterm Exam Questions and Answers

Document preview thumbnail
Preview 4 out of 32 pages

PHP Midterm Exam Questions and Answers

Content preview

PHP Midterm Exam Questions and
Answers


Select the answer that is NOT a PHP data type.



Undefined

Array

Float

NULL - Answer-Undefined



Which statement is often used to display output in PHP?



printScreen

screenPrint

echo

display - Answer-echo



If you need to know the data type and value of a PHP variable, you should use the _______________
function.



var_dump

toString

,typeof

type_of - Answer-var_dump



When you create PHP constant values, you can indicate if the constant is case-sensitive.



True

False - Answer-True



PHP is currently utilized in a majority of websites.



True

False - Answer-True



To generate a random number in PHP, you should use the __________ function.



serialize

rand

random

randNum - Answer-rand



PHP variable names start with which symbol?



!

$

&

,# - Answer-$



PHP code is executed in the browser.



True

False - Answer-False



PHP variable names are case-sensitive.



True

False - Answer-True



Like JavaScript, you can concatenate PHP strings with the + operator



True

False - Answer-False



function addCoffee(&$word) { $word = $word . "coffee"; }

$myWord = "Good";

addCoffee($myWord);

echo $myWord;



What will the output be?



Good coffee

, Good

Error! There's an ampersand in the parameter.

Goodcoffee - Answer-Goodcoffee



$x = 5; $y = 10;

Select the if statement that will output "Hello!" when $x is equal to 5 or when $y is equal to 10, but will
not create output if both are true.

if ($x === 5 Or $y === 10) { echo "Hello!"; }

if ($x === 5 xor $y === 10) { echo "Hello!"; }

if ($x === 5 || $y === 10) { echo "Hello!"; }

if ($x === 5 && $y === 10) { echo "Hello!"; } - Answer-if ($x === 5 xor $y === 10) { echo "Hello!"; }



When constructing a Switch statement, every case should end with a _________________ until you
reach the default code to be executed.



conditional

exception

break

continue - Answer-break



By default, PHP is a strictly typed language.



True

False - Answer-False



I am concerned that my PHP form may be easily hacked with XSS. I am going to use the
htmlspecialchars() function to prevent this. What does htmlspecialchars() do?

Document information

Uploaded on
January 17, 2025
Number of pages
32
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$17.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Zanaya
4.5
(12)
Sold
77
Followers
29
Items
10176
Last sold
3 days ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions