ITIS 3105

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

How many operands does a ternary operator have?

3

Which PHP class can be used to connect to a MySQL database?

PDO

Which of the following is a class used for errors thrown by the PDO library?

PDOException

In the catch block of a try/catch statement for handling PDO exceptions, you can get a message that describes the exception by using the getMessage method of the

PDOException object

What generates the HTML that is returned in a HTTP response

PHP

A web server receives a HTTP request for a PHP page, the web server calls the

PHP interpreter

What is the default name of a session_cookie in PHP

PHPSESSID

Not a database that can be used for dynamic web pages

Python (not a database)

What is stored in $message by the code that follows? $message = "The file is in \"C:\\My Documents\"";

The file is in "C:\My Documents"

Run a PHP application

Uses local host as the domain name

Which MySQL statement is used to get the variable length of strings

VARCHAR

Which cluase in a SQL statement specifies the records to return based on criteria?

WHERE

While loops and for loops are often referred to as ______________ structures.

iteration

How data passed to data in form

method

Consists of PHP files that represent the data of the applications

model

To make a variable that is declared outside of a function usable inside the PHP function, which keyword can be used?

global

Which PHP function returns a string with all special HTML converted to the HTML entity?

htmlentities

PHP function converts some special characters into character entities

htmlspecialcharacters

Function used to forward a request from one PHP file to another

include

Switch statement in PHP is often useful in the __________ controller

of an application

Each row in a table should be uniquely identified by a

primary key

Sends a value back to where the function was called?

return

Which PHP function is used to create a cookie?

setcookie

In PHP, all variable begin with

$

To get the value of a cookie, you can use the auto global ________________ variable.

$_COOKIE

Auto global used to get and set the users data for a session

$_SESSION

Not a valid way to create a timestamp

$birthdate=mktime(12,2,1969)

Assume that the POST method is used. Which of the following statements gets the value of the radio button that's on in the delivery group and stores it in a variable named $card_type? <input type="radio" name="delivery" value="USPS" />USPS <input type="radio" name="delivery" value="FedEx" />Federal Express <input type="radio" name="delivery" value="UPS" />UPS

$card_type = $_POST['delivery'];

When you get values of radio button, what will the value be?

$card_type = filter_input(INPUT_POST, 'delivery');

To create a DateTime object that represents a due date that's 90 days after the current date, you use the following code:

$days = new DateInterval('P90D'); $due_date = new DateTime(); $due_date = $due_date->add($days); (Technically, the book says that: $due_date->add($checkout_length); is the proper way to use the ->add() method without the $due_date = to the left.

Suppose that $name contains a last name followed by a comma and a space, followed by a first name. Then, you can store the first and last names in variables with code like this:

$i = strpos($name, ', '); $last_name = substr($name, 0, $i); $first_name = substr($name, $i+2);

Which of the following is a parameter of the setcookie function

$name $value $expire

Suppose that $name contains a last name followed by a comma and a space, followed by a first name. Then you can store the first and last names in variables with code like this:

$name = explode( ', ', $name ); $last_name = $name[0]; $first_name = $name[1];

If you want to generate a random number that ranges form 1,000 to 500,000 as a multiple of 100 (1000, 1100, 1200, etc.), and store it in a variable named $number, you can use the code that follows.

$number = mt_rand(10, 5000); $number *= 100;

If a request is not sent, a session will end by default after ___________ have passed

24 minutes

Separate the original URL from the parameters

?

Which of the following statements about associative arrays in NOT true?

You can use a foreach loop to access the values of an associative array but not the indexes.

When you use session tracking, each HTTP request includes

a cookie that stores the session ID

An index for a PHP array:

can be a number or a string

Which type of input element should be used on a form when the user can select zero, one, or many of the options in a group?

checkbox

print echo

echo $votingAge

When you use the header function to redirect a request

A response is returned to the browser that tells it to request another page

What type of loop executes at least once?

do-while

A hidden field

doesn't appear on the form but its data is sent to the server

Which of the following can be used in a conditional expression?

equality relational logical

Which MySQL statement is used to modify the column of an existing table

ALTER TABLE

To add a column to the table after the database has been created use the

ALTER TABLE statement

A software that is a web server

Apache

Which of the following is not a benefit o fusing MVC pattern for an application?

Application runs more efficiently

function get_product($product_id) { global $db; $query = 'SELECT * FROM products WHERE productID = :product_id'; $statement = $db->prepare($query); $statement->bindValue(':product_id', $product_id); $statement->execute(); $product = $statement->fetch(); $statement->closeCursor(); return $product; } What does this function return when it is called?

Array of column in the first row with the specified product ID (Fetch gets one row at a time)

A switch statement in PHP starts by evaluating a switch

expression

Which of the following can be used to get the data from an array that contains all rows of a result set? a. foreach statement b. forall loop c. fetch d. roll over

foreach statement

I f 2 tables have a one-to-many relationship, you may need to a add a _______________ column to the table on the many side

foreign key

When you ________ a request, all processing takes place on the server.

forward

HTTP response for a dynamic web page is passed

from the web server to the browser

Which of the following can a SELECT statement not do to the data in a table? a. Delete the rows b. Sort the rows c. Get selected rows d. Get selected columns

Delete the rows

An INSERT statement, you do not have to include the data for a column that

has a default value

When creating a function, ________ can be included in the parenthesis that follow the name

parameters

A cookie that does not expire when the user closes his or her browser is a ____________ cookie.

persistent

Very row is identified by a ________________

primary key

What does a relational database use to uniquely identify each row in a table?

primary keys

The first part of the URL is called the

protocol

A natural comparison of two values

puts both "09" and "9" before 10

User can only select one file option

radio

If statement can be used to implement a ___________ structure

selection

When you create a PDO object, you have to pass all but one these arguments to it: Which one is it?

server name

What PHP function can be used to end a session?

session_destroy

PHP function used to start a new session or resume a previous session

session_start

To delete a cookie, you

set the cookie's value to an empty string and its expiration date to a time in the past

Function for sorting arrays

sort rsort ksort

Special type of array that implements last in, first out

stack

When HTML pages were first developed, web pages were typically

static

Gaps can be introduced into an array in all of the ways that follow, except one. Which one is it?

store an empty value in an array

Which PHP function returns the number of characters in the string

strlen

Consider the following code example: <h1>Future Value Calculator</h1> <?php if (!empty($error_message)) { ?> <p class="error"><?php echo $error_message; ?></p> <?php } ?> <form action="display_results.php" method="post"> <div id="data"> <label>Investment Amount:</label> <input type="text" name="investment" value="<?php echo $investment; ?>"/><br /> <label>Yearly Interest Rate:</label> <input type="text" name="interest_rate" value="<?php echo $interest_rate; ?>"/><br /> <label>Number of Years:</label> <input type="text" name="years" value="<?php echo $years; ?>"/><br /> </div> If this code is from the first page of this application, what does the if statement in the PHP tag do the first time this page is executed?

Doesn't do anything because $error_message will be empty

What type of SQL statement specifies the table(s) that supply the data retuned?

FROM

Column definition for a MySQL used to determine all but

what range of values

Which character is used to separate parameters that are appended

&

Array uses strings as indexes

associative array

function get_product($product_id) { global $db; $query = 'SELECT * FROM products WHERE productID = :product_id'; $statement = $db->prepare($query); $statement->bindValue(':product_id', $product_id); $statement->execute(); $product = $statement->fetch(); $statement->closeCursor(); return $product; } Which of the following is the proper PHP statement for calling the function in this example and storing the returned result in a variable named $product.

$product = get_product($product_id); $ - variable function names don't start with variable

Which of the following is the correct syntax for using a conditional operator

(conditional_expression) ? value_if_true : value_if_false

Which of the following is NOT an escape sequence used in double-quoted strings in PHP?

/c

If total months....

1 years and 1 month

How many radio buttons from the following code can be selected at any given time? <input type="radio" name="address" value="Home" />Home Address <input type="radio" name="delivery" value="FedEx" />Federal Express <input type="radio" name="delivery" value="UPS" />

2

SELECT vendorName, invoiceNumber, invoiceDate, invoiceTotal FROM vendors INNER Join invoices ON vendors.vendorID = invoices.vendorID WHERE invoiceTotal >= 500 ORDER BY vendorName DESC How many columns will the result set have?

4

After the if statement that follows is executed, what will be the value of $discountAmount be? $discountAmount; $order_total = 200; if ($order_total > 200 ) { $discountAmount = $order_total * .3; } else if ($order_total > 100) { $discountAmount = $order_total * .2; } else { $discountAmount = $order_total * .1; }

40

Which of the following is a relational operator in PHP

< <= >

Which of the following is considered the assignment operator in PHP?

=

What is not a MySQL data type?

CHR

_________ provide a way for web application to store information in the user's web browser and retrieve it every time the user requests a page

Cookies

Which MySQL statement is used to delete a table

DROP table

The ________ for a MySQL connection specifies the host computer for the MySQL database and the name of the database.

DSN (Data Source Name)

When gets the value of the radio button that's on in the delivery group and stores it as a variable named $card_type

FedEx

Form appends values to get the URL to pass data

GET

Method of the form appends values to the URL to pass data

GET

Type of request does a web browser typically send to a server

HTTP

What type of SQL statement returns data from more than one table?

JOIN

hen you use the MVC pattern, you

Make each layer as independent as possible

The MVC acronym stands for

Model View Controller

What type of SQL statement specifies how the result set should be sorted

ORDER BY

What type of SQL statement returns a result set

SELECT

What type of SQL statement specifies the columns to return?

SELECT

Which MySQL statement is used to select a database?

USE

SELECT vendorName, invoiceNumber, invoiceDate, invoiceTotal FROM vendors INNER Join invoices ON vendors.vendorID = invoices.vendorID WHERE invoiceTotal >= 500 ORDER BY vendorName DESC What table(s) does the data in the result set come from?

Venders and Invoices

Assume that the statements that follow get the data from a text area named comments. After these statements are executed, how will the $comments variable be displayed by an echo statement? $comments = $_POST['comments']; $comments = htmlspecialchars($comments);

With character entries for special characters

URL specifies a directory that doesn't contain a default page, Apache displays

a list of all the directories in that folder

If venderName contains

alphabetically starting with Z

The easiest way to add the values in an array is to use

array sum function

Which of the following functions removes the next element in a LIFO array (also known as a stack)?

array_pop

HTML properties are called

attributes

Which type of statement ends the current iteration of a loop?

break

A web applications a type of

client/server application

Key consists of more than one field

composite key

In the code that follows, if $error_message isn't empty if ($error_message != '') { include ('index.php'); exit(); }

control is passed to a page named index.php that's in the current directory

Receives request from users, get the appropriate data and returns the appropriate views to the user

controller

When you use htmlspecialcharacters and nl2br functions to process a user's entry and pass to a webpage the browser will

display the html tags entered by the user instead of processing them

Which function redirects a request to another URL?

header

Deploy a PHP application on your own computer, copy the application not the directory

htdocs directory on an Apache server

Order of precedence for arithmetic expressions causes

increment operators to be done first

A ___________ provides a way for databases management system to locate information more quickly.

index

Which of the following can be displayed if you omit the file name

index.html(2) index.html(3) index.php(1)

A ______ is a positive or negative number with no decimal places

integer

Variable substitution is carried out by what process that converts a variable's value to a string?

interpolation

The $_SESSION variable for a session

is an associative array

A PHP variable name

is case sensitive

One reason for using the header function to redirect a request

is to have a PHP file run itself again (To redirect a file use function: header) (To forward a request: include)

Determines if checkbox is checked?

isset

Isn't a privilege for modifying the database structure that can be assigned to a user

keys

The HTML tag used to load the external style sheet

link

Form element determines how data is passed

method

Which of the following is a PHP function to get random numbers?

mt_rand

Which optional attribute of a select element allows the user to select more than one option in a list box?

multiple

In order to group multiple radio buttons so that only one of the radio buttons can be selected at a time, which attribute of the input element must have the same value for all radio buttons in the group?

name

Suppose that $name contains a last name followed by a command space $name explode

name[0] name[1]

If a row in one table is related to just one row in another table, the tables are said to have a

one-to-one relationship

Which HTML element is used to create items in a drop-down list?

option

When you ________ a request, the server returns a response that tells a browser

redirect

Refers to modifying the organization or structure of an application

refactoring

If you want to round a number within an arithmetic expression, which function should you use?

round

An error that occurs after an application is running is known as a

runtime error

Which parameter of the session set_cookie params can be set so the cookie is only available in http

secure

Used to create a drop down list

select

A PHP function that returns the sum of elements in an array

sum_array

<input> tags display

text boxes that contain the data

When you use the MVC pattern, the controller gets the HTTP requests and then directs the use of the files that represent

the model and the view

When you use the sir function to extract a substring from a substring, you need to at least pass an argument that gives

the string position of the substring

You can deal with gaps in all but one of the following ways. Which one is it?

use the array_fill function to replace all gaps n the array with the empty string

The value of the htmlspecialchars and nl2br functions is that they let you display

user entries just as they were entered

Consists of PHP and HTML files that represent the user interface

view

The column definition for a MySQL table can be used to determine all but one of the following. Which one is it? a. whether the column can contain a null value b. whether the column has a default value c. What type of data the column can contain d. what range of values the column can contain

what range of values the column can contain

MySQL

whether count can what range (Select, balance, number)

$months=5

while ($i> $months) =0

When you create a DateInterval object, you pass it one argument that specifies one or more of the following

years, months, weeks, days, hours, minutes, seconds

Which of the following statements about arrays is true

you can use both for loops and foreach loops to work with an array of arrays


Kaugnay na mga set ng pag-aaral

Chapter 22 Vet Diagnostic Imaging: Dental Radiography

View Set

Public Health - Quiz and Kahoot for Exam 2

View Set

Anatomy Chapter 16: The Digestive System

View Set

Medical Surgical Chapter 58 URinary

View Set

Blood bank exam 2 (chapter 5, 8,9,10)

View Set

Chapter 14: Myocardial Infarction

View Set

FIN 320 Chapter 11 & 12 Market Efficiency

View Set