INFO263

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

To send the output from printf to a variable instead of to a browser, what alternative function would you use?

sprint(), this can be assigned to a variable and wont be outputted to the browser.

What is the main benefit of using a function?

Avoids the need to repeats similar sections of code.

Why is the password_hash function a powerful security measure?

Because is is a one-way function that is hard to crack.

Why do you suppose that an underscore is allowed in variable names ( $current_user ), whereas hyphens are not ( $current-user )?

Because the hyphen is used for subtraction this makes the language ambiguous.

Why must a cookie be transferred at the start of a program?

Because they are sent as part of the headers.

How can you create a multiline echo or assignment?

Between speech marks you can press enter to create a new line or use the <<<_END..._END to create multiline variables.

What is the best way to force your own operator precedence?

To use brackets around the operators you want high precedence.

You can submit form data using either the POST or the GET method. Which associative arrays are used to pass this data to PHP?

$_GET and $_POST

How would you create a Unix timestamp for 7:11 a.m. on May 2, 2016?

$timestamp = mktime(7, 11, 0, 5, 2, 2016);

Which printf conversion specifier would you use to display a floating-point number?

%f, e.g. printf("fav num is %f", $num);outputs "fav num is 7.000000"

What is the difference between $variable = 1 and $variable == 1 ?

'$variable == 1' is checking to see if the variable is equal to 1 whereas '$variable = 1' is setting the variable to 1

What command can you use to skip the current iteration of a loop and move on to the next one?

'continue' statement

Which file access mode would you use with fopen to open a file in write and read mode, with the file truncated and the file pointer at the start?

'w+', or seen as $fh = fopen{"testfile.txt", 'w+');

What tag is used to invoke PHP to start interpreting program code? And what is the short form of the tag?

<?php...?>, <?...?>

Which of the following tag styles is preferred in HTML5: <hr> or <hr />?

<hr /> is the used in the older XHTML, but both are accepted and it's up to the user

How is an object different from a function?

A function is a chunk of code that is referenced by a name that can receive and output values. An object can hold functions (called methods) and variables (called properties) all combined.

What is a PHP session?

A group of variables that are unique to the user and are passed along with successive requests so the variables are always available even after changing pages.

What is the result of combining a string with a number?

A string with the number added

What can a variable store?

A string, Boolean, number or other.

What is the difference between a numeric and an associative array?

A value in a numeric array can be indexed by numbers. Associative arrays use 'strings' or Keys to index values.

How do if and while statements interpret conditional expressions of different data types?

Both expect a Boolean answer and trigger if it evaluates to True, Numeric expressions are True when non zero, String expressions are True when not empty and a NULL expression is evaluated as False.

What is the difference between ++$j and $j++ ?

Both increment the variable but '++$j' is incrementing the variable before an operation but '$j++' is incrementing after the operation.

What is the difference between foreach and each?

Both loop through an array and return elements.

How can you create a multidimensional array?

By creating arrays in arrays

How can you cause an object to be initialized when you create it?

By creating the __construct method, any code in it will be ran when making an instance of the class.

Why is it a good idea to explicitly declare properties within a class?

By explicitly declare properties(e.g. public $name = 'Fletcher';) instead of implicitly (e.g. $object1->name = 'Fletcher';) This improves code readability and helps people maintain the code.

If you generate data within a function, what are a couple of ways to convey the data to the rest of the program?

By outputting the variable or by putting a '&' before the input on a function variable name.

How can you set PHP's internal pointer into an array back to the first element of the array?

By the reset function. This is used when using the next() and current() functions.

Which HTML tag is used to encapsulate a form element and supporting text or graphics, making the entire unit selectable with a mouse-click?

By using the <label> </label> tags.

What syntax would you use to create a subclass from an existing one?

By using the class (initiates the new class) and extends keywords e.g. class Subclassname extends Parentclassname

How can you submit a form field without displaying it in the browser?

By using the type="hidden". This hides the entire field from the user

What is meant by salting a string?

Extra characters are added to make sure people with the same passwords don't have the same hash value.

Why is a for loop more powerful than a while loop?

For loops support two extra parameters that let you control the loop handling.

Name the three conditional statement types.

If, Switch and the ? If : Operator.

How can you incorporate one PHP file within another?

Include or require both incorporate another file, but include_once and require_once should be used so you're not including a file twice accidentally.

What are the simplest two forms of expressions?

Literals (e.g. Numbers and Strings) and Variables. These are the simplest as they evaluate themselves.

How can you make a variable accessible to all parts of a PHP program?

Making it a global variable

Can you redefine a constant?

No

Can you use spaces in variable names?

No, this would confuse the PHP interpreter. '_' are used instead.

How many values can a function return?

One, but by using arrays and global variables it can return multiple values.

How do you convert one variable type to another (say, a string to a number)?

PHP automatically converts a variable when referenced

If a form has to offer three choices to a user, each of which is mutually exclusive so that only one of the three can be selected, which input type would you use, given a choice between checkboxes and radio buttons?

Radio buttons, Check boxes allow multiple selections.

How can you destroy a cookie?

Reissue the cookie with an expiry date in the past

Which character must be placed at the end of every PHP statement?

Semi colon ;

What are the two types of comment tags?

Single line '//' and multi line comments '/*'.

What is the difference between a text box and a text area?

Text box is single line and Text Area can accept multiple lines and have word wrapping

What form attribute can be used to help users complete input fields?

The 'autocomplete' attribute prompts users with possible values.

How can you determine the number of elements in an array?

The 'count' function e.g count($array);

How can you ensure that an input is completed before a form gets submitted?

The 'required attribute.

How do you initiate a PHP session?

The 'session_start' function.

How can you submit a group of selections from a web form using a single field name?

The choices are entered into an array with square brackets such as choices[].

What is the difference between unary, binary, and ternary operators?

The difference is the amount of operands each require. Unary, binary, and ternary have 1, 2 and 3 operands respectively.

What is meant by operator associativity?

The direction of processing for operators.

Which PHP function converts HTML into a format that can be displayed but will not be interpreted as HTML by a browser?

The htmlentities function

What is the meaning of scope in PHP?

The parts of a program which can access a variable.

Which PHP function stores a cookie in a web browser?

The set_cookie function

Where are the username and password stored in a PHP program when you are using HTTP authentication?

The user at $_SERVER['PHP_AUTH_USER'] $_SERVER['PHP_AUTH_PW']

What is the difference between the echo and print commands?

They are similar as they are both constructs, but print can only take one argument.

What is session hijacking?

When a hacker knows a users session ID and uses it

What is the purpose of functions?

To separate code into pieces with their own self-contained sections that can be referenced by their own function name.

What is the purpose of the explode function?

To separate sections of a string separated by a given character. Such as separating words with spaces between them.

What actual underlying values are represented by TRUE and FALSE ?

True is 1, False is NULL and gets outputted as nothing.

What is the PHP command for deleting the file file.txt ?

Unlink("file.txt");

How do you create a new object in PHP?

Use the 'new' keyword, e.g. $object = new Class;

What is session fixation?

When a hacker gets a user to log in with the wrong Session ID.

When would you use the === (identity) operator?

When wanting to check if two values are the exact same (Type as well). Ignoring PHP's type casting.

What is the difference between accessing a variable by name and by reference?

When you reference a variable by name, such as by assigning its value to another variable or by passing its value to a function, its value is copied. The original does not change when the copy is changed. But if you reference a variable, only a pointer (or reference) to its value is used, so that a single value is referenced by more than one name. Changing the value of the reference will change the original as well.

Which symbol is used to preface all PHP variables?

With exception to constants, dollar sign $

Are variable names case-sensitive?

Yes, $this is not equal to $This

Are the operators && and 'and' interchangeable?

Yes, but '&&' has higher precedence.

What is the main benefit of the array keyword?

You can add multiple values at once

Which PHP function is used to read in an entire file in one go, even from across the web?

file_get_contents, also can read file

How do you escape a quotation mark?

You can use /' or/", for example $text = "She wrote upon it, \"Return to sender\".";

Which PHP superglobal variable holds the details on uploaded files?

_FILES

Which PHP function enables the running of system commands?

exec, enables the running of system commands.

What printf statement could be used to take the input string "Happy Birthday" and output the string "**Happy"

printf("%'*7.5s", "Happy Birthday");


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

Macro-Econ:Ch1 Limits, Alternatives and Choices

View Set

Emberi Erőforrások A. tételsor/ 1. tétel

View Set

Colonial Latin American Social Classes

View Set

Ch. 14/15/16/30 Peri-op and Post-op care

View Set

Chapter 5: Health Education and Health Promotion, PATIENT EDUCATION AND HEALTH PROMOTION

View Set