CPSC 431

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which of the following is NOT a problem of working with flat files in PHP?

When a file becomes small, working with it can be very slow.

What is the purpose of the semicolon in PHP

Statement termination

Which of the following PHP array operators signifies non-identity?

!==

Write a statement that accesses the contents of the field SERVER_NAME in an array variable named $_SERVER.

$_SERVER['SERVER_NAME']

Which of the following statements tests for equality between the PHP variables $a and $b?

$a == $b

Define a PHP variable $c that is a copy of object $b of the same class with the same attribute values

$c = clone $b;

Define an object named $c that instantiates an instance of the class MyClass, using no parameters

$c = new MyClass();

You need to open a file orders.txt for writing. Modify the following code, specifically the two placeholder, to accomplish your goal

$fp = fopen("document_root/orders.txt", 'w');

Edit the following code to accomplish the goal of reversing the array created by range() $numbers = range(1,10); $numbers = _____($numbers);

$numbers = array_reverse($numbers);

Create a PHP array called $numbers with elements ranging from 1 to 100

$numbers = range(1,10);

Given the following $products definition, perform an ascending alphabetical sort on its contents

$products = array('Tires', 'Oil', 'Sparks Plugs');

Create an array (using full PHP syntax) named $products that contains the values: gum, spam, and eggs

$products = array('gum', 'spam', 'eggs');

Which of the following expressions shows a correct PHP array definition?

$products = {'Tires', 'Oil', 'Spark Plugs'};

Replace the first element of the $products array with Fuses

$products[0] = 'Fuses';

Assign the literal value 0.000 to the variable named $totalamount

$totalamount = 0.00;

Which of the following statements if true concerning PHP functions?

** a) PHP function names cannot begin with a digit b) PHP functions can have the same name as an existing function c) PHP functions must include parameters d) PHP function names can contain only letters, digits, and underscores

Which of the following symbols represent a single-line comment in PHP?

//

Write a single-line PHP comment that says "Hello World"

// Hello World

PHP indexes start at ______ by default

0

MySQL is an example of a(n):

RDBMS

Which of the following statements is false concerning PHP identifiers?

a. Identifiers cannot begin with a digit. b. Identifiers can be of any length. ** c. Identifiers are case insensitive. d. Identifiers can have the same name as a function.

In object-oriented programming, _______ are properties or variables that relate to an object

attributes

Modify the following code to specify that the B class is a subclass of the A class.

class B extends A { }

Edit the following PHP class definition to add a public attribute named attribute1

class Myclass { public $attribute1; }

Make a call to a PHP function named compute by passing in the variable 42

compute(42);

The PHP statement $a = new classname("First"); denotes a(n):

constructor

Which of the following is a PHP function used to declare constants

define

Echo the string $hello world in such a way that the $hello variable's contents are interpolated into the output.

echo "$hello world";

Use PHP to echo the size of the file orders.txt that's present in your current working directory

echo filesize("orders.txt")

Use the ______ keyword to specify that one class is to be a subclass of another

extends

Use PHP to close the file $fp programmatically

fclose($fp)

In PHP, a while loop tests for the end of the file by using which function?

feof()

The statement $products{0} access the _______ element in an array

first

To open a file in PHP, you use the ______ function

fopen()

Define a function named my_function that has no parameters and echoes the string function called

function my_function() { echo 'function called'; }

Write a function named table that accepts a parameter called data and echoes the string table created.

function table($data) { echo 'table created'; }

Modify the following PHP function code to ensure that only the first echo statement is executed. Make your edit as compact as possible, using the blank underline as your guide. function test_return() { echo "This statement will be executed"; ______ echo "This statement will never be executed"; }

function test_return() { echo "This statement will be executed"; return; echo "This statement will never be executed"; }

Use the PHP fwrite function to write the string stored in $outputstring to the file pointed to by $fp

fwrite($fp, $outputstring);

The _______ construct can be used to split an array into a number of values

list()

PHP variables that are declared inside a function are known as:

local variables

An array containing other arrays is known as a(n) ________ array

multidimensional

Create a namespace named orders to hold all your order-related PHP code

namespace orders;

What is the role of 'foo' in the PHP statement function('foo');?

parameter

Disable PHP from opening files via fopen() and FTP by editing:

php.in

The object-oriented principle of _______ means that different classes can have different behaviors for the same operation

polymorphism

A PHP function that calls itself is known as a ______ function

recursive

Use the PHP require statement to include the contents of the file reusable.php in your current script

require('reusable.php');

The PHP keyword return

stops the execution of a function

You need to use a PHP while loop to read from a file until the end of the file is reached. Modify the following code to accomplish your goal.

while(!feof($fp))


Set pelajaran terkait

mgmt 308 Chapter 5 Ethics and Ethical Reasoning

View Set

Introduction to Python 3 Programming

View Set

Microbiology Lab Midterm Study Guide

View Set

AP Biology Lab 2.08-2.09: Tonic Osmoregulation and Transport

View Set