Question
True
False
click below
click below
Question
Group of answer choices
False
True
Normal Size Small Size show me how
PHP Arrays and Funcs
SA2
Question | Answer |
---|---|
Each member of the array index references a corresponding value and can be a simple numerical reference to the value’s position in the series, or it could have some direct correlation to the value. True False | True |
Global Variables is declared inside a function and is only available within the function in which it is declared. Group of answer choices False True | False, should be local |
What is the keyword use to gain access a variable that is outside of the function? Group of answer choices Call Default Overall Global | Global |
You can create your own function inside of a php code Group of answer choices False True | True |
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. Group of answer choices False True | True |
$f = array( '102' => "red", '101' => "blue", '100' => "yellow"); krsort($f); print_r($f); What is the output of the code? | Array ( [102] => red [101] => blue [100] => yellow ) |
param – is the formal parameters of the function. Parameter must follow the rule of naming dentifier. Group of answer choices True False | True |
Array is used to aggregate a series of similar items together. Group of answer choices False True | True |
$fruit = array(“orange”,”apple”,”grape”,”banana”); What is the value of index 0? | orange |
You can create a function inside of a function Group of answer choices True False | True |
$f = array( '102' => "red", '101' => "blue", '100' => "yellow"); ksort($f); print_r($f); What is the output of the code? | Array ( [100] => yellow [101] => blue [102] => red ) |
Sorts by key in reverse order Group of answer choices krsort($array) usort($array) ksort($array) kusort($array) | krsort($array) |
Sorts by a function Group of answer choices krsort($array) usort($array) ksort($array) kusort($array) | usort($array) |
function a($a,$b){ return $a+$b; } echo a(6,5); what is the value of $a? 11 6 Error 5 | 6 |
prints additional information about the size and type of the values it discovers | var_dump() |
foreach($arr as ______) $value val val$ value$ | $value |
sort(), asort(), and ksort() functions are used to sort elements in the array in ascending order. Group of answer choices True False | True |
is one that declared outside a function and is available to all parts of the program. | Global Variables |
Function count($val){ static $c = 0; $c += $val; echo $c; } Count(4); Count(3); What is the output of the code? | Error, Count() != count() |
is a statement used to iterate or loop through the element in an array. | foreach() |
Sorts by value in reverse order; assign new number as the keys | rsort($array) |
PHP array does not need to declare how many elements that the array variable have. Group of answer choices False True | True |
specify an array expression within a set of parenthesis following the foreach keyword. Group of answer choices False True | True |
$s = “variable”; function f(){ global $s; echo “function called ”; echo “$s”; } f(); what is the output of the code? | function called variable |
$t = 100; function one(){ echo “1000”; } one(); what is the value of the $t after execute the code? | 100 pa rin duh |
it is required to create a function name for a function Group of answer choices True False | True |
foreach(____ as $value) Group of answer choices arr$ array $arr arr | $arr |
$g = 200; function a(){echo “5”;} function b(){echo “4”;} b(); what is the output of the code? | 4 |
The foreach statement is use to iterate through the element in an array. Group of answer choices False True | True |
Sorts by value; keeps the same key | asort($array) |
Syntax of a function Group of answer choices Param (function name){} Param_function Function name {param} Function name(param){} | Function name(param){} |
functions that are built-in into PHP to perform some standard operations | predefined functions |
What is the output? function disp(){ function disp2(){ echo “hello”; } } disp(); disp2(); | hello |
Sorts by value in reverse order; keeps the same key | arsort($array) |
$num=array(1,2,3,4,5); foreach(num as $val){ echo $val; } Check the code if valid or invalid? | Invalid, no $ before num |
You can pass values to a function and you can ask functions to return a value. Group of answer choices True False | True |
Array can be used as ordinary array same as in C and C++ arrays. Group of answer choices False True | True |
foreach($arr as ___ => $value){ //do something } $get $set $var $key | $key |
Syntax for foreach Group of answer choices foreach($arr){} foreach{}($arr as $value) foreach($value){} foreach($arr as $value){} | foreach($arr as $value){} |
You can use only 10 for Array elements Group of answer choices False True | False |
Local Variables is one that declared outside a function and is available to all parts of the program. Group of answer choices True False | False, should be global |
$f = array( '102' => "red", '101' => "blue", '100' => "yellow"); ksort($f); print_r($f); What is the key of the yellow? | still 100 |
is declared inside a function and is only available within the function in which it is declared. | local variable |
function keyword is used in PHP to declare a function. Group of answer choices False True | True |
You use can functions in different ways. Group of answer choices True False | True |
is a group of PHP statements that performs a specific task. Functions are designed to allow you to reuse the same code in different locations. Group of answer choices Arrays Variables Operators Functions | Functions |
functions that are provided by the user of the program. | user DEFINED function |
$fruit = array(“orange”,”apple”,”grape”,”banana”); What is the value of index 1? | apple |
Functions can only have 1 parameter Group of answer choices True False | False |
asort(), ksort(), arsort(), and krsort() maintains its reference for each values. Group of answer choices True False | True |
function a($a,$b){ return $a+$b; } echo a(5,4); what is the name of the parameter? | a (referring to function name perhaps) |
Using foreach statement you can display both the keys and value of each element in the array. Group of answer choices True False | True |
$num=array(1,2,3,4,5); foreach($num as $val){ echo $val; } What is the output of the code? | 12345 |
function disp(){ function disp2(){ echo “hello”; } } Disp(); disp2(); | error, Disp() is different from disp() |
You can insert CCS code inside of a function Group of answer choices False True | True |
var_dump function is same as print_r function except it adds additional information about the data of each element. Group of answer choices True False | True |
Function count($val){ static $c = 0; $c += $val; echo $c; } count(4); count(3); What is the output of the code? | 47 |
$g = 200; function a(){echo “5”;} function b(){echo “4”;} a(); what is the output of the code? | 5 |
A function that is declared inside a function is said to be hidden. Group of answer choices True False | True |
$s = “variable”; function f(){ global $s; echo “function called ”; echo “$s”; } f(); what is the output of the code? | function called variable |
Array can be used as ordinary array same as in Group of answer choices Python C and C++ Java Ruby | C and C++ |
function a($a,$b){ return $a+$b; } echo a(6,5); what is the value of $a? | 6 |
return the value length of a string Group of answer choices lenstr lengthstring strlen stringlen | strlen |
Syntax to make a string’s first character uppercase Group of answer choices string ucfirst(string $str) string fsupper(string $str) string firstcu(string $str) string upperfs(string $str) | string ucfirst(string $str) |
Most of the developers used include functions for their Group of answer choices Content Titles Body Footer | Footer / Header |
Syntax to strip HTML and PHP tags from a string. | string strip_tags(string $str [, string $allowable_tags ]) |
Including files can use to write their database connection and so on. Group of answer choices False True | True |
Number format can include thousand separator Group of answer choices False True | True |
Make a string’s first character uppercase | ucfirst() |
converts string to lowercase Group of answer choices strlow strtolower stringtolow lowerstr | strtolower |
Syntax for maximum value Group of answer choices mixed big(mixed $value) mixed max(mixed $value) mixed top(mixed $value) mixed high(mixed $value) | mixed max(mixed $value) |
Number format can show or hide the decimal places Group of answer choices False True | True |
Syntax to get a part of a given string string strpart ( string $string , int $start [, int $length ] ) string strsub ( string $string , int $start [, int $length ] ) string substr ( string $string , int $start [, int $length ] ) | string substr ( string $string , int $start [, int $length ] ) |
In some scripts, a file might be included more than once, causing function redefinitions, variable reassignments, and other possible problems. Group of answer choices False True | True |
Syntax for include once Group of answer choices filename(“include_once”); Include_once(“filename.inc”); Include_once(filename.inc); Include_once(filename.php); | Include_once(“filename.inc”); |
$g = 200; function a(){echo “5”;} function b(){echo “4”;} ab(); what is the output of the code? | error |
is a statement used to iterate or loop through the element in an array. | foreach() |
sort(), asort(), and ksort() functions are used to sort elements in the array in ascending order. True False | True |
You can create your own function inside of a php code Group of answer choices False True | True |
function disp(){ function disp2(){ echo “hello”; } } disp2(); | error, cannot call nested functions w/o calling parent func first |
Format character for ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) | N |
used to format a local time and date | date() |
Format character for numeric representation of the day of the week | w |
syntax for position of a string? | int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) (correct choice shows strops) |
In including files You may write the file with an extension name of ______ rather than .php to serve as a fragment of your program code. | .inc |
returns part of a given string Group of answer choices strsub partstr strpart substr | substr |
Split a string by string Group of answer choices Explode Implode Unset Destroy | explode |
Syntax to stripped white spaces or other characters from the beginning and end of a string. | string trim(string $str [, string $charlist ]) |
Syntax for include Group of answer choices include(filename.inc); filename(“include”); include(filename.php); include(“filename.inc”); | include(“filename.inc”); |
find the position of the first occurrence of a substring in a given string Group of answer choices stringpos strpos posstr posstring | strpos |
$x = max(5.3, 5 , 6, 3);echo $x; What is the output? | 6 |
Function can only do something without passing values. Group of answer choices True False | False? |
Array index in PHP can be also called as array storage Group of answer choices True False | False, should be keys |
Sorts by value; assign new numbers as the keys | sort($array) |
$s = “variable”; function f(){ echo “function called ”; echo “$s”; } f(); what is the output of the code? function variable function called undefined variable: s function called variable function called | function called undefined variable: s |
Syntax for implode? string implode ( string $glue , array $pieces ) string implode ( array $pieces ) string implode ( int $glue , array $pieces ) string implode ( array $pieces ) | string implode ( string $glue , array $pieces ) string implode ( array $pieces ) |
$x = floor(5.2);echo $x; What is the output? | 5 |
Syntax to strip white spaces or other characters form the end of a string. | string rtrim(string $str [, string $charlist ]) |
Format character for a two digit representation of a year Choices: y Y C R | y (lower case) |
$x = ceil(5.2);echo $x; What is the output? | 6 |
$x = max(10, 5 , 3, 20);echo $x; What is the output? | 20 |
converts the first character of each word in a string to uppercase | ucwords() |
used to generate random integers | rand() |
syntax for reverse a string | string strrev (string $string) |
Syntax for random number with minimum and maximum value Group of answer choices int rand(int $min, int $max) int random(int $min, int $max) int ran(int $min, int $max) int rndm(int $min, int $max) | int rand(int $min, int $max) |
A constant’s value cannot be changed. Group of answer choices False True | True |
Format character for a full number representation of a year, 4 digits | Y (upper case) |
29/30 | |
Function count($val){ $c = 0; $c += $val; echo $c; } count(10); count(5); What is the output of the code? | 105, $c is not declared as static |
Sorts by value in reverse order; assign new number as the keys | rsort() |
Syntax of a function Group of answer choices Function name {param} Function name(param){} Param_function Param (function name){} | Function name(param){} |
asort(), ksort(), arsort(), and krsort() maintains its reference for each values. Group of answer choices False True | True |
specify an array expression within a set of parenthesis following the foreach keyword. Group of answer choices True False | True |
Functions are designed to allow you to reuse the same code in different locations. Group of answer choices True False | True |
function disp(){ function disp2(){ echo “hello”; } } disp(); disp2(); what is the output? | hello |
$t = 100; function one(){ echo “value”; } one(); what is the function name inside of the code? | one |
define(‘Max_n’,10); What is the name of the define function? Group of answer choices Define Max_n Max 10 | Max_n |
Syntax for a number format Group of answer choices number_format set_digit number_set format_digit | number_format |
Syntax for require once Group of answer choices require_once(filename.inc); require_once(filename.php); require_once(“filename.inc”); filename(“require_once”); | require_once(“filename.inc”); |
Format character for English ordinal suffix for the day of the month, 2 characters Group of answer choices C D E S | S |
Format character for a textual representation of the day, three letters Group of answer choices d D DAY day | D |
syntax to transform a string to upper case Group of answer choices string strupper (string $str) string strtoupper (string $str) string upperstr (string $str) string stringtoupper (string $str) | string strtoupper (string $str) |
There will be a warning text if the include file not found Group of answer choices True False | True |
stripped white spaces or other characters from the beginning and end of a string. Group of answer choices trim() set() get() strip() | trim() |
$x = rand(5,10);echo $x; What is the minimum value of the output? Group of answer choices 0 5 10 Error | 5 |
Format character for a full textual representation of the month, such as January or March Group of answer choices M T J F | F |
$val=234123.456; echo number_format($val); what is the output? Group of answer choices 234,123.46 234,123 234,123.4560 234123.46 | 234,123 when no other arguments, adds commas and rounds decimals |
Format character for lowercase Ante meridiem and Post meridiem Group of answer choices P a p A | a |
$x = floor(7.2);echo $x+1; What is the output? Group of answer choices Error 8 9 Blank | 8 |
returns the next highest integer by rounding the value upwards Group of answer choices up() ceil() top() high() | ceil() |
Syntax of define Group of answer choices define(‘name’); define(‘NAME’,’value’); define(‘value’); define(‘value,’NAME’’); | define(‘NAME’,’value’); |
$x = min(7, 4.7 , 4.25 , 5);echo $x; What is the output? Group of answer choices 4.7 4.25 7 5 | 4.25 |
Format character for whether it’s a leap year Group of answer choices L y Y l | L |
Format character for numeric representation of a month, with leading zeroes Group of answer choices r m f n | n |
$val=643322.7834 echo number_format($val,3,’.’,’,’); what is the output? Group of answer choices 643,322.7834 643322.7834 643,322.783 643322.78 | 643,322.783 |
$t = 100; function one(){ echo “1000”; } one(); what is the value of the $t after execute the code? | 100 |
Functions can be user defined generally defined by the user of the program and predefined that are build in using libraries. Group of answer choices False True | True |
$g = 200; function a(){echo “5”;} function b(){echo “4”;} b(); what is the output of the code? | 4 |
function a($a,$b){ return $a+$b; } echo a(5,4); what is the output of the code? | 9 |
destroys the specified variable Group of answer choices destroy implode explode unset | unset |
Syntax for ceil Group of answer choices ceil float ($value) $ceil ($float) $value (ceil) float ceil (float $value) | float ceil (float $value) |
string white spaces or other characters from the beginning of a string | ltrim() |
Syntax that used to format a local time and date Group of answer choices string date(string $format [, int $timestamp = time() ]) string time string $format [, int $timestamp = time() ]) () | string date(string $format [, int $timestamp = time() ]) |
You can separate your PHP file and embed it to your html by using PHP include functions. Group of answer choices True False | True |
$val=356342.783 echo number_format($val,2,’.’,’’); what is the output? 356,342.783 356342.783 356,342.78 356342.78 | 356342.78 |
String number_format( float $number, int _____; ) Group of answer choices $thousands_sep $dec_points $decimals $points | $decimals |
What do you call a function inside of a function Group of answer choices Loop function Double function Nested function Function fun | Nested Function |
PHP has a built-in function to perform operations Group of answer choices False True | True |
Format character for a full textual representation of the day of the week Group of answer choices t l d w | l |