Lis4381 exam 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which character is used to signify the end of the string in a PHP regular expression?

$

To refer to a public property named categoryName for an object that's referenced by $category, you code

*** $category->categoryName

You can use the __________________________ variable within a class to refer to the current object that has been created from the class.

*** $that

To call a static method named randomize in a class named Cart, you code (this operator allows access to static, constant, and overridden properties or methods of a class)

*** cart::randomize()

When you use object-oriented techniques to implement the MVC pattern, the model consists of _________________________________ that contain the required methods.

*** classes

When you use inheritance to create a new class from an existing class, the new class starts with the public properties and _________________________________ of the existing class.

*** constants

Within a function, you can use the ________________ keyword if you need to refer to a variable that's declared outside the function.

*** global

To code a method within a class that sets the value for a private property named $name based on the argument that's passed to it, you start with this code:

*** private function setName($value) {

Within a function, you can end the function and pass the result back to the calling statement by coding a _____________________ statement.

*** return

This pattern can be used to validate a five-digit zip code:

/^\d{5}$/

Because most systems today store timestamps as 32-bit signed integers, the upper limit of a timestamp on these systems is January 19 in the year ______________________.

2038

Why is it important not to begin an integer value with a zero (e.g., 03), when working with numbers in calculations?

Because it would be treated as an octal value, and yield an incorrect result.

The diff method of a DateTime object requires another DateTime object as its argument and returns a ______________________________ object.

DateInterval

One of the methods of a ______________________________ object lets you add a DateInterval object to the object.

DateTime

The use of _________________________ objects resolves the Y2K38 problem because the upper limits of dates and times are essentially removed

DateTime

If a number in a PHP application is larger than the maximum value that PHP provides for, it is converted into the PHP constant named _________________________.

INF

With the use of the following escape sequences, 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"

To avoid the duplication of function names, you can

Use namespaces

Which character is used to signify the beginning or the end of a word in a PHP regular expression?

\B

Which of the following will match any character that is NOT a letter, number, or underscore in a PHP regular expression?

\W

Which of the following will match any digit in a PHP regular expression?

\d

Which of the following will match any letter, number, or underscore in a PHP regular expression?

\w

Which character is used to signify the beginning of the string in a PHP regular expression?

^

$current_date = new DateTime(); $due_days_diff = $current_date->diff($due_date); if ($current_date > $due_date) { $overdue_message = $due_days_diff->format( '%y years, %m months, and %d days overdue.'); } If $due_date contains a DateTime object, $due_date_diff will contain

a DateInterval object

Thefunctionthatfollowsreturns function coin_toss() { if (mt_rand(0,1) == 0) { $coin = 'heads'; } else { $coin = 'tails'; } return $coin; }

a value of either "heads" or "tails"

in php, function name duplications are likely to occur because

all functions have global scope

To call a function, you code the function name followed by a set of parentheses that contains a list of the required __________________________.

arguments

Regular expressions

can be used to completely validate some types of user entries

if you create a function that passes an argument by reference, the function

can change the original variable without using a return statement

The strcasecmp function is _________________________. As a result, "Anders" comes before "zylka".

case-insensitive

If you want to code a catch block that catches all types of exceptions and gets the message associated with the exception, you start the catch block like this:

catch (Exception $e) {

A __________________________ defines the methods and properties of an object.

class

A static property or method is one that belongs to a __________________________, not to an object.

class

To create a class in PHP, use the ____ keyword to write a class definition.

class

___ are the functions and variables defined in a class.

class members

The ____ function determines whether a class exists and is available to the current script.

class_exists()

Objects are organized into ____.

classes

A __________________________ is a special method within a class that is executed when a new object is created from the class.

constructor

Information contained within variables is called ____.

data

Class variables are also known as ____.

data members

Type casting refers to PHP code that converts a value from one _________________ to another.

data type

The explode function returns an array of strings from a single string based on the _________________________ character that you specify.

delimiter

In order to print out a variable's value, when you code a variable name within a string literal, you have to enclose the literal within __________________________ quotation marks.

double

Objects in which all code and required data are contained within the object itself are ____.

encapsulated

What will be returned if you use a local variable outside the function in which it is declared?

error message

By using ____________________, you can put special characters into a string literal that would otherwise be interpreted incorrectly by PHP.

escape sequences

Runtime errors that occur due to unexpected error conditions are called ________________.

exceptions

A function library is just a ____________________ that contains one or more functions.

file

All of the arguments that are passed to a function are available in an array that can be accessed by using the

func_get_args function

if you create a function with a variable number of parameters, you need to use a special php _____ to get an array of the arguments that are passed to the function.

function

To create a function named randomize that has one parameter that has a default value of 5 and one required parameter that's passed by reference, you start the function like this:

function randomize(&$parm1, $parm2 = 5) {

With many programming languages, global variables are automatically available to all parts of your program, including ____.

functions

To get the message that's related to an exception, you use the

getMessage method of the exception object

In PHP, all functions have ________________ scope.

global

Class members that other programmers do not need access to should be ___.

hidden

By using the ____________________ function, you can send special characters to the browser in a way that they will be displayed correctly.

htmlentities

What modifier can be added to the end of a regular expression in PHP to make it case insensitive?

i

In an if statement, which is a correct right way to find out whether the string in $a comes before (is less than) the string in $b in a case-insensitive comparison?

if ((strtolower($a) < (strtolower($b))

A particular instance of an object ___ the methods and properties of its class.

inherits

An object created from an existing class is called a(n) ___

instance

Use the ____ comparison operator to determine whether an object is instantiated from a given class.

instanceof

___ the object means creating an object from a class.

instantiating

A substring within a string is identified by its ______________________ and its ______________________ within the string.

length, starting position

The parameters within the parentheses of a function declaration are what kind of variables?

local

if you declare a variable within a function, the variable has ____ scope.

local

The ____________________ function returns the largest value of the two or more arguments that are passed to it.

max ()

A hyphen and a greater-than symbol (->) used to access (or "call") the methods and properties contained in an object are referred to as ____.

member selection (or, object access modifier) notation

Class functions are called ____.

methods

To create an object from a class named Cart that requires two arguments, you code

new Cart($arg1, $arg2)

To create a DateTime object for the current date, you use the _________________ and pass no arguments to the constructor.

new keyword

Programming code and data that can be treated as an individual unit or component is known as a(n) ____.

object

Reusable software objects that can be incorporated into multiple programs is called ____.

object-oriented programming

When you use object-oriented techniques to implement the MVC pattern, the methods of the model return the data as either arrays or

objects

When a new class extends a superclass, it inherits the properties and methods of the superclass. Then, it can _______________ by providing your own versions.

override the inherited methods

A DateInterval object represents a/an _________________ time.

period of

Which function searches for a regular expression in a string and returns 1 if the pattern is found?

preg_match

___ are variables associated with an object.

properties

To enable anyone to call a class's member function use a(n) ____.

public access specifier

To code a constructor for a class named Cart that requires two arguments, you start with this code:

public function __construct($arg1, $arg2) {

To prevent other classes from directly accessing the properties of a class, you can code them as private. Then, to make them available to other classes, you can code

public methods to set and get their values

Which of the following are coded patterns that you can use to search for matching patterns in text strings?

regular expressions

The ltrim and rtrim functions let you ______________________ from the front or back of a string.

remove all spaces

The date function makes it easy to create a timestamp for the current date and then _______________________ before returning the value.

return a string formatted as a date

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

round

When you use a variable in a PHP program, you must be aware of the variable's ____.

scope

A timestamp stores the number of ____________________ since midnight on January 1, 1970 GMT.

seconds

After you create a DateTime object, you can use its setTime method to change the time or its _________________ method to change the date.

setDate

A list of functions or methods in the reverse order in which they were called is a(n)________________.

stack trace

Which of the following functions returns the length of a string (i.e., number of characters that it contains)?

strlen()

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

the starting position of the substring

When you declare a global variable with the global keyword, you do not need to assign the variable a(n) ____.

value

by default, all arguments for php functions are passed by ____.

value

Using strnatcasecmp($str1, $str2) function for a "natural" comparison of two values

would evaluate both "09" and "9" as being before "10"

When you create a DateInterval object, you can use the format() method, and pass it a number of arguments that specifies a format code for one or more of the following descriptions:

years, months, days, hours, minutes, seconds, and sign (+ or -) of the date interval


संबंधित स्टडी सेट्स

Environmental Science Chapter 6 Test

View Set

Chapter 6 Strengthening a Company's Competitive Position: Strategic Moves, Timing, and Scope of Operations

View Set

Enlightenment, French Revolution, 18th Century Europe

View Set

Business Law for Accountants Chapter 38

View Set

Chapter 8: Love and Communication in Intimate Relationships

View Set