Save
Upgrade to remove ads
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

FA3 & FA4 Appdev

FA3 Appdev

QuestionAnswer
___ is used to aggregate a series of similar items together, arranging and dereferencing them in some specific way. A. Function B. Array C. Index D. Variable Array (An array groups similar items and allows indexed access to each element.)
foreach($arr as ___ => $value){ //do something } A. $set B. $get C. $var D. $key $key (The foreach key-value syntax uses $key => $value to access both the key and value of each element.)
Functions are designed to allow you to reuse the same code in different locations. True (Code reuse is one of the core purposes of functions in any programming language.)
Local Variables is one that declared outside a function and is available to all parts of the program. False (That describes a Global variable. A local variable is declared inside a function and only accessible within it.)
$fruit = array("orange","apple","grape","banana"); What is the value of index 3? banana (Arrays are 0-indexed: index 0=orange, 1=apple, 2=grape, 3=banana.)
$g = 200; function a(){echo "5";} function b(){echo "4";} a();b(); What is the output of the code? A. 45 B. 200 C. 54 D. Error 54 (a() echoes "5" then b() echoes "4", so the combined output is 54.)
Functions are limited to 1 per code only. False (PHP allows you to define as many functions as needed in a single script.)
8. function count($val){ static $c = 0; $c += $val; echo $c; } Count(4); Count(3); What is the output of the code? A. 47 B. 43 C. Error D. 7 47 (The static keyword retains the value between calls. First call: 0+4=4 (echoes 4). Second call: 4+3=7 (echoes 7). Output = 47.)
$a[]="mango"; $a[]="apple"; $a[]="banana"; Check the code if valid or invalid? A. Invalid B. Valid Valid (Using $a[] without specifying an index is valid PHP shorthand for appending to an array.)
$g = 200; function a(){echo "5";} function b(){echo "4";} a(); What is the value of the $g? A. 4 B. 200 C. Error D. 5 200 (Function a() only echoes "5" — it does not modify $g. The variable remains 200.)
var_dump function is same as print_r function except it adds additional information about the data of each element. True (var_dump() shows the type and value of each element, while print_r() only shows the value.)
___ references a corresponding value. A. Array number B. Array collection C. Array index D. Array setting Array index (An array index (key) references/points to its corresponding value in the array.)
$t = 100; function one(){ echo "1000"; } one(); What is the value of the $t after executing the code? A. 1000 B. 100 C. 1 D. Error 100 (The function only echoes "1000" but does not modify $t. Its value stays 100.)
___ functions that are provided by the user of the program. A. Predefined function B. User function C. Program function D. User defined function User defined function (Functions written by the programmer/user of the program are called user defined functions.)
$s = "variable"; function f(){ echo "function called "; echo "$s"; } f(); What is the output of the code? A. function called variable B. function called C. function called undefined variable: s D. function variable function called undefined variable: s
Array can be used as ordinary array same as in C and C++ arrays. True (PHP arrays support numeric (integer) indexing just like arrays in C and C++.)
___ functions that are built-in into PHP to perform some standard operations. A. Predefined functions B. User defined functions C. Program functions D. User function Predefined functions (Built-in PHP functions (like strlen, array_push, etc.) are called predefined functions.)
Functions can only have 1 parameter. False PHP functions can accept zero, one, or multiple parameters.
Syntax for foreach A. foreach($arr as $value){} B. foreach($arr){} C. foreach($value){} D. foreach{}($arr as $value) foreach($arr as $value){} The correct foreach syntax is: foreach(array as $value){ } or foreach(array as $key => $value){ }
What is the keyword used to gain access to a variable that is outside of the function? A. Global B. Overall C. Default D. Call Global The global keyword lets a function access a variable from the outer (global) scope.
Most of the developers used include functions for their ___ A. Footer B. Titles C. Content D. Body Footer (Footer and header files contain standard layout code that is identical on every page, making them the primary use case for include functions.)
Format character for day of the month without leading zeros A. d B. m C. j D. z j (day without leading zeros (1–31). d = with leading zeros (01–31). m = month with leading zeros. z = day of the year.)
$x = ceil(10.01); echo $x; What is the output? A. Blank B. Error C. 10 D. 11 11 (ceil() always rounds a fractional number UP to the next highest integer. Even 10.01 becomes 11.)
In some scripts, a file might be included more than once, causing function redefinitions, variable reassignments, and other possible problems. True (Using include/require multiple times can cause fatal errors like "Cannot redeclare function." Use include_once or require_once to prevent this.)
Same as require function except it includes the file only once. A. require B. include_once C. include D. require_once require_once (require_once behaves like require (halts on failure) but ensures the file is only loaded once, preventing redefinition errors.)
$x = rand(5,10); echo $x; What is the maximum value of the output? A. Error B. 5 C. 10 D. 0 10 (rand(min, max) is inclusive of both bounds. The highest possible value is 10.)
___ returns the next lowest integer by rounding the value downwards A. round() B. floor() C. down() D. bottom() floor() (floor() rounds down to the next lowest integer (e.g., floor(10.99) = 10). down() and bottom() are not valid PHP functions. )
___ converts string to lowercase A. lowerstr B. strtolower C. stringtolow D. strlow strtolower (strtolower() is the built-in PHP function to convert all characters in a string to lowercase. The other options are not valid PHP functions.)
___ Split a string by string A. Unset B. Destroy C. Explode D. Implode Explode (explode() breaks a string into an array based on a delimiter. Implode() does the opposite — joins array elements into a string.)
Syntax for include once A. filename("include_once"); B. Include_once(filename.php); C. Include_once(filename.inc); D. Include_once("filename.inc"); Include_once("filename.inc"); (The filename must be a quoted string. Without quotes, PHP treats it as a constant and throws an error.)
Key word to declare a define function A. define B. defined C. def D. dfn define (define() creates a constant (e.g., define("MIN_AGE", 18)). defined() checks if a constant exists. def and dfn are not valid PHP keywords.)
A constant's value cannot be changed. True (Once defined using define() or const, a constant's value stays fixed throughout the entire script execution.)
___ converts the first character of each word in a string to uppercase A. wordsuc() B. ucwords() C. uwords() D. cwords() ucwords() ucwords() stands for "uppercase words." Example: ucwords("hello world") returns "Hello World". The others are not valid PHP functions.
Syntax to get a part of a given string string substr ( string $string , int $start [, int $length ] ) substr() is the built-in PHP function to extract a part of a string. strpart, partstr, and strsub do not exist in PHP.
There will be a warning text if the include file not found True include issues an E_WARNING and allows the script to continue. This differs from require, which throws a fatal error and halts execution.
$val=234123.456; echo number_format($val); What is the output? A. 234,123.46 B. 234123.46 C. 234,123 D. 234,123.4560 234,123 number_format() with one argument defaults to 0 decimal places and adds a comma as the thousands separator. .456 rounds down to 0.
___ can only be assigned a scalar value, like a string or a number. A. Contrast B. Construct C. Constant D. Define Constant A constant can only hold scalar values (int, float, string, bool) or arrays (in newer PHP versions). Its value cannot be changed once set.
___ Return the smallest value Choices A. small() B. tiny() C. low() D. min() min() min() returns the lowest value from a set of numbers or an array. Example: min(2,3,1,6,8) returns 1. The others are not valid PHP functions.
Syntax to strip white spaces or other characters from the beginning and end of a string. string trim(string $str [, string $charlist ]) trim() strips whitespace (or specified characters) from both ends of a string. ltrim() trims the left only; rtrim() trims the right only.
Format character for English ordinal suffix for the day of the month, 2 characters A. D B. E C. S D. C S S in PHP's date() function returns the ordinal suffix: st, nd, rd, or th — depending on the day (e.g., 1st, 2nd, 3rd, 4th).
What is the result of the code? function c1($n,$m){ echo $n+$n; } function c2($n,$m){ echo $n-$m; } function c3($n,$m){ echo $n*$m; } $v=15; if ($v<15) { c1($v,7); } elseif($v<20) { c2($v,5); } else { c3($v,3); } 10
What is the result of the code? function mf($n){ echo "program"; } echo "number"; mf(5); programnumber number program numberprogram numberprogram
What is the array index of the value gold? $ranks = array("bronze","silver","gold","platinum"); 1 2 3 gold 2
What is the result of the code? function m($n){ echo $n*2; } function n($n){ echo $n*3; } $v=2; if($v>5) { m($v); } else { n($v); } 4 6 2 5 6
How many indexes/elements are in the array item? $item = array("card", "pen", "paper", "scissor"); PHP $item = array("card", "pen", "paper", "scissor"); Choices: 1 2 3 4 4
What is the output of the code? PHP function mf(){ echo "my code"; } echo "call function"; mf(); Choices: my code call function call functionmy code my codecall function call functionmy code
A group of statements that performs a specific task: Choices: variables arrays functions constants functions
What is the result of the code? PHP function r($m){ echo $m + $m; } $b = 5; r($b); Choices: 5 25 10 Error 10
Sorts array by value: Choices: ksort() asort() sort() rsort() sort()
What is the result of the code? PHP function mf($n){ echo "prog".$n; } echo "space"; mf(5); Choices: prog5 space spaceprog5 prog5space spaceprog5
A statement used to iterate or loop through the elements in an array? Choices: for while do...while foreach foreach
What is the result of the code? PHP $item=array("card","pen","paper","scissor"); echo $item[1]; Choices: card pen paper scissor pen
What is the output of the code? PHP function mf(){ echo "mycode"; } echo "call function"; Choices: mycode call function call functionmycode Blank call function
To create a function you always need a parameter. False
What is the result of the code? PHP $color = array("white","green","red"); echo $color[3]; Choices: red white error null error
What is the result of the code if the variable v is equal to 10? PHP function m($n){ echo $n*2; } function n($n){ echo $n*3; } $v=10; if($v>5) { m($v); } else { n($v); } Choices: 20 30 10 5 20
What is the result of the code? PHP $color = array("white","green","red"); echo $color[0]; Choices: white green red error white
What is the result of the code if the condition of $v>5$ changed into $v<5$?PHPfunction m($n){ echo $n*2; } function n($n){ echo $n*3; } $v=2; if($v<5) { m($v); } else { n($v); } Choices:6 4 2 10 4
What is the output of the code? PHP function disp(){ function disp2(){ echo "hello"; } } disp(); disp2(); Choices: hello error disp blank hello
You can use functions in different ways. True
Question: PHP $f = array('102' => "red", '101' => "blue", '100' => "yellow"); ksort($f); print_r($f); What is the key of "yellow"? Choices: 102 101 100 0 100
Question: Functions can be user-defined (generally defined by the user of the program) and predefined (that are built-in using libraries). True
You can create a function inside of a function. True
Global Variables are declared inside a function and are only available within the function in which they are declared. False
Array index in PHP can also be called as array storage. False
$g = 200; function a(){echo "5";} function b(){echo "4";} b(); What is the output of the code? Choices: 200 5 4 Error 4
_ is used to retain the values between separate calls to the same function. Choices: Local Variables Global Variables Static Variables Constant Variables Static Variables
$s = "variable"; function f(){ echo "function called"; echo "s"; } f(); What is the output? Choices: function called variable function calleds function called function calleds
Array index in PHP can also be called: Choices: Array lists Array storage Array keys Array values Array keys
The foreach statement is used to iterate or loop through the elements in an array. True
Which function is used to print the readable array structure? Choices: echo print print_r var_dump_structure print_r
_ is the keyword used to declare a function. Choices: def function declare fn function
What do you call a function defined inside of another function? Choices: Double function Sub function Nested function Internal function Nested function
Using a foreach statement, you can display both the keys and values of each element in the array. True
A PHP array does not need to declare how many elements the array variable will have. True
Sorts an array by value in reverse order while keeping the same key associations: Choices: rsort() arsort() krsort() sort() arsort()
$t = 100; function one(){ echo "value"; } one(); What is the function name inside of the code? Choices: value one $t execute one
You must specify an array expression within a set of parentheses following the foreach keyword. True
$g = 200; function a(){echo "5";} function b(){echo "4";} ab(); What is the output of the code? Choices: 54 200 error blank error
A function can be put anywhere in the code layout. True
Syntax to convert the first character of each word in a string to uppercase: Choices: string strtoupper(string $str) string ucfirst(string $str) string ucwords(string $str) string cwords(string $str) string ucwords(string $str)
Join array elements to form a single string: Choices: explode split implode merge implode
Syntax for finding the minimum value: Choices: mixed small(mixed $value) mixed low(mixed $value) mixed min(mixed $value) mixed min_value(mixed $value) mixed min(mixed $value)
You may write a file with an extension name of ___ rather than .php to serve explicitly as a fragment of your program code. Choices: .inc .html .txt .code .inc
Syntax to transform a string completely to uppercase: Choices: string ucwords(string $str) string strtoupper(string $str) string stringtoupper(string $str) string upper(string $str) string strtoupper(string $str)
Return the value length of a string: Choices: count sizeof strlen strpos strlen
Format character for numeric representation of a month, with leading zeroes: Choices: F m M n m
Syntax for getting the length of a string: Choices: int length(string $string) int count(string $string) int strlen(string $string) int str_len(string $string) int strlen(string $string)
$x = rand(5,10); echo $x; What is the minimum value of the output? Choices: 0 1 5 10 5
$x = min(7, 4.7, 4.25, 5); echo $x; What is the output? Choices: 7 4.7 4.25 5 4.25
Format character for a full numeric representation of a year, 4 digits: Choices: y Y r g Y
Find the position of the first occurrence of a substring in a given string: Choices: strstr strchr strpos stringpos strpos
Reverse a given string: Choices: reverse strrev string_reverse revstr strrev
Syntax for generating a random integer: Choices: int random(void) int rand(void) int generate_rand(void) int rnd(void) int rand(void)
Format character for numeric representation of the day of the week: Choices: d D w l w
Complete the parameters: PHP string number_format( float $number, int $_______ ) Choices: $thousands_sep $decimals $dec_point $format $decimals
Format character for checking whether it's a leap year: Choices: l L y Leap L
Syntax for rounding a value downwards: Choices: down() floor() ceil() round_down() floor()
returns the next highest integer by rounding the value upwards Choices: round() floor() ceil() highest() ceil()
Syntax for getting the maximum value: Choices: mixed max (mixed $value) mixed high (mixed $value) mixed top (mixed $value) mixed maximum (mixed $value) mixed max (mixed $value)
Format character for a two-digit representation of a year: Choices: Y y g d y
$x = max(5.3, 5, 6, 3); echo $x; What is the output? Choices: 5.3 5 6 3 6
PHP $x = min(10, 5, 3, 20); echo $x; What is the output? Choices: 10 5 3 20 3
Format character for a short textual representation of a month, three letters: Choices: m M F n M
Strip whitespaces or other characters from the beginning of a string: Choices: rtrim() trim() ltrim() strip_start() ltrim()
Performs the same way as the include function, but generates a fatal error message if the file is not found, stopping the script at that point. Choices: include_once require require_once request require
$val = 234123.456; echo number_format($val); What is the output? Choices: 234123.46 234,123.46 234,123 234,123.456 234,123
$fruit = array(“orange”,”apple”,”grape”,”banana”); What is the value of index 1? Group of answer choices grape banana orange apple apple
Function can only do something without passing values. False.
We use static keyword to declare a variable inside a function that will act as accumulator variable this will let the program remember the last value of the variable that was used. True
Sorts by value; assign new numbers as the keys Group of answer choices sort($array) arsort($array) rsort($array) asort($array) sort($array)
function a($a,$b){ return $a+$b; } echo a(5,4); what is the output of the code? Group of answer choices 5 9 4 Error 9
To gain access to a variable that is outside from the function we use the global keyword. Group of answer choices True
Local Variables is one that declared outside a function and is available to all parts of the program. False
function disp(){ function disp2(){ echo “hello”; } } disp2(); Group of answer choices disp error hello blank error
Syntax of a function Group of answer choices Function name {param} Param (function name){} Function name(param){} Param_function Function name(param){}
sort() and rsort() does not maintain its index reference for each values. True
You use can functions in different ways. Group of answer choices True
You can pass values to a function and you can ask functions to return a value. True
PHP array does need to declare how many elements that the array variable have. False
Sorts by a function Group of answer choices usort($array) kusort($array) ksort($array) krsort($array) usort($array)
Join array elements to form a string A. Explode B. Implode C. Unset D. Destroy Implode
Reverse a given string A. stringrev B. revstr C. revstring D. strrev strrev
Syntax of define A. define('value','NAME'); B. define('NAME','value'); C. define('value'); D. define('name'); define('NAME','value'); The correct syntax is define('NAME', 'value') — the constant NAME comes first, then the value.
$x = min(10, 5, 3, 20); echo $x; What is the output? Choices A. 20 B. 3 C. 5 D. 10 3 min() returns the smallest value from the given set. From 10, 5, 3, 20 — the smallest is 3.
Format character for lowercase Ante meridiem and Post meridiem Choices A. A B. P C. p D. a a a returns lowercase am or pm. A (uppercase) returns AM or PM. P and p are not valid date format characters for this purpose.
Format character for the day of the year (starting from 0) Choices A. x B. y C. d D. z z z returns the day of the year starting from 0 (0 through 365). d = day of the month with leading zeros (01–31). y = two-digit year. x is not a valid date format character.
$val = 643322.7834; echo number_format($val, 3, '.', ','); What is the output? Choices A. 643322.7834 B. 643,322.783 C. 643,322.7834 D. 643322.78 643,322.783 number_format($val, 3, '.', ','): 3 decimal places rounds .7834 to .783; dot is the decimal separator; comma is the thousands separator. Result: 643,322.783
returns part of a given string Choices A. strpart B. partstr C. strsub D. substr substr substr() is the built-in PHP function to return a part of a string. Syntax: string substr(string $string, int $start [, int $length]). strpart, partstr, and strsub are not valid PHP functions.
Which of the following is NOT part of the functions for array manipulation? Choices A. Unset B. Explode C. Implode D. Destroy Destroy Destroy is not a valid built-in PHP array manipulation function. The valid ones are: unset(), explode(), implode() , session_destroy()
Syntax for length of a string Choices A. int strlen(string $string) B. int stringlen(string $string) C. int lenstr(string $string) D. int lengthstring(string $string) int strlen(string $string) strlen() is the correct built-in PHP function for returning the length of a string. stringlen, lenstr, and lengthstring are not valid PHP functions. Example: strlen("Hello") returns 5.
Format a number with grouped thousand Choices A. Number set B. Number format C. Format digit D. Set digit Number format number_format() is the built-in PHP function used to format a number with grouped thousands. Example: number_format(217795.75) returns 217,796. The other options are not valid PHP functions.
Syntax for implode string implode(int $glue, array $pieces) string implode(array $pieces) int implode(int $glue, array $pieces) string implode(array $pieces) string implode(string $glue, array $pieces) string implode(array $pieces) string implode(string $glue, array $pieces) string implode(array $pieces) implode() returns a string (not int), and $glue is a string (the separator), not an int. Example: implode(",", ["orange","apple","banana"]) returns "orange,apple,banana".
returns the next highest integer by rounding the value upwards Choices A. up() B. top() C. ceil() D. high() ceil() ceil() rounds a value UP to the next highest integer. Example: ceil(10.01) = 11, ceil(4.3) = 5. up(), top(), and high() are not valid PHP functions.
Used to format a local time and date Choices A. time() B. date() C. time_date() D. date_time() date() date() is the built-in PHP function used to format a local time or date.
Most of the developers used include functions for their ___ Choices A. Titles B. Footer C. Body D. Content Footer Developers commonly use include functions for header and footer files — since these contain standard layout code that remains identical across multiple pages. Content/Body usually changes dynamically per page.
Syntax to strip HTML and PHP tags from a string string tags_get(string $str[, string $allowable_tags]) string strip_tags(string $str[, string $allowable_tags]) string tags_search(string $str[, string $allowable_tags]) string strip_tags(string $str[, string $allowable_tags]) strip_tags() removes all HTML and PHP tags from a string. $allowable_tags is optional — it lets you specify tags to keep. Example: strip_tags(" Hello World ") returns "Hello World".
$x = rand(5,10); echo $x; What is the maximum value of the output? Choices A. 10 B. Error C. 5 D. 0 10 rand(min, max) generates a random integer inclusive of both bounds. The minimum possible output is 5 and the maximum possible output is 10.
Syntax for maximum value Choices A. mixed top(mixed $value) B. mixed big(mixed $value) C. mixed high(mixed $value) D. mixed max(mixed $value) mixed max(mixed $value) max() is the correct built-in PHP function for returning the highest value. top(), big(), and high() are not valid PHP functions. Example: max(2,3,1,6,8) returns 8.
returns part of a given string (Syntax version) string strpart(string $string, int $start[, int $length]) string partstr(string $string, int $start[, int $length]) string substr(string $string, int $start[, int $length]) string substr(string $string, int $start[, int $length]) substr() is the built-in PHP function to extract a part of a string. strpart, partstr, and strsub do not exist in PHP.
Created by: user-2041815
 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards