click below
click below
Normal Size Small Size show me how
App Dev
SA2
| Question | Answer |
|---|---|
| $t = 100; function one(){ echo "1000"; } one(); what is the value of the $t after execute the code? | 100 |
| It is declared inside a function and is only available within the function in which it is declared. | Local variables |
| $g = 200; function a(){echo “5”;} function b(){echo “4”;} a(); what is the output of the code? | 5 |
| $t = 100; function one(){ echo “value”; } one(); what is the function name inside of the code? | one |
| $mo = array(“jan”,”feb”,”mar”); echo “<pre>”; var_dump ($mo); echo “</pre>”; Check the code if valid or invalid? | Valid |
| Functions are limited to 1 per code only True or False | False |
| $fruit = array(“orange”,”apple”,”grape”,”banana”); What is the value of index 0? | orange |
| $a[]=”mango”; $a[]=”apple”; $a[]=”banana”; Check the code if valid or invalid? | Valid |
| What do you call a function inside of a function Group of answer choices Loop function Function fun Double function Nested function | Nested function |
| rsort(), arsort(), and krsort() functions are used to sort elements in the array in descending order. True or False | True |
| specify an array expression within a set of parenthesis following the foreach keyword. True or False | False |
| functions are commonly used for debugging. The point of this of these functions is to help you visualize what’s going on with compound data structures like arrays. print_c() and var_info() print_p() and var_add() print_r() and var_dump() | print_r() and var_dump() |
| $fruit = array(“orange”,”apple”,”grape”,”banana”); What is the value of index 3? | banana |
| 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 or False | True |
| PHP has a built-in function to perform operations True or False | True |
| function keyword is used in PHP to declare a function. True or False | True |
| A function that is declared inside a function is said to be hidden. True or False | True |
| function disp(){ function disp2(){ echo “hello”; } } Disp(); disp2(); error disp blank hello | error |
| 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 or False | True |
| $g = 200; function a(){echo “5”;} function b(){echo “4”;} a(); what is the value of the $g? | 200 |
| This takes an argument of any type and prints it out, which includes printing all its parts recursively. | print_r() |
| Sorts by value; keeps the same key rsort($array) sort($array) arsort($array) asort($array) | asort($array) |
| Function count($val){ $c = 0; $c += $val; echo $c; } count(10); count(5); What is the output of the code? | 105 |
| $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 ) |
| function disp(){ function disp2(){ echo “hello”; } } disp2(); | error |
| $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 ) |
| $s = “variable”; function f(){ echo “function called ”; echo “$s”; } f(); what is the output of the code? function called function called undefined variable: s function called variable function variable | function called undefined variable: s |
| 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. | Functions |
| ksort() and krsort() used to sort elements by values. True or False | False |
| Using foreach statement you can display both the keys and value of each element in the array. True or False | True |
| Function count($val){ static $c = 0; $c += $val; echo $c; } Count(4); Count(3); What is the output of the code? | error |
| Global Variables is declared inside a function and is only available within the function in which it is declared. True or False | False |
| What is the keyword use to gain access a variable that is outside of the function? Call Default Global Overall | Global |
| Sorts by key in reverse order | krsort($array) |
| function is used to print the array structure. | print_r() |
| Array index in PHP can be also called as array storage True or False | False |
| is used to retain the values calls to the same function. | Static variables |
| function disp(){ function disp2(){ echo “hello”; } } disp(); disp2(); | hello |
| asort(), ksort(), arsort(), and krsort() maintains its reference for each values. True or False | True |
| Function can have a return value True or False | True |
| is one that declared outside a function and is available to all parts of the program. | Global variables |
| $f = array( '102' => "red", '101' => "blue", '100' => "yellow"); ksort($f); print_r($f); What is the key of the yellow? 100 Error 102 101 | 100 |
| foreach($arr as ___ => $value){ //do something } $set $key $var $get | $key |
| PHP array does not need to declare how many elements that the array variable have. True or False | True |
| PHP array does need to declare how many elements that the array variable have True or False | False |
| is a statement used to iterate or loop through the element in an array. everyone() everyeach() foreach() seteach() | foreach() |
| foreach(____ as $value) $arr arr arr$ array | $arr |
| $g = 200; function a(){echo “5”;} function b(){echo “4”;} ab(); what is the output of the code? 54 200 error 45 | error |
| $num=array(1,2,3,4,5); foreach($num as $val){ echo $val; } What is the output of the code? Error 1 12345 5 | 12345 |
| asort() and arsort() used to sort elements by keys. True or False | False |
| Sorts by value in reverse order; assign new number as the keys | rsort($array) |
| Sorts by a function | usort($array) |
| Array index is also known as Array Keys. True or False | True |
| functions that are provided by the user of the program. Program function User defined function User function Predefined function | User defined function |
| function a($a,$b){ return $a+$b; } echo a(5,4); what is the output of the code? 9 5 Error 4 | 9 |
| it is required to create a function name for a function True or False | True |
| $mo = array(“jan”,”feb”,”mar”); echo “<pre>”; print_r ($mo); echo “</pre>”; Check the code if valid or invalid? | Invalid |
| references a corresponding value. Array index Array number Array setting Array collection | Array index |
| $num=array(1,2,3,4,5); foreach(num as $val){ echo $val; } Check the code if valid or invalid? | Invalid |
| You can pass values to a function and you can ask functions to return a value. True or False | True |
| function a($a,$b){ return $a+$b; } echo a(6,5); what is the value of $a? | 6 |
| param – is the formal parameters of the function. Parameter must follow the rule of naming dentifier. True or False | True |
| Function can be put anywhere of the code | True |
| Functions can only have 1 parameter | False |
| Syntax for foreach foreach($arr as $value){} foreach($arr){} foreach{}($arr as $value) foreach($value){} | foreach($arr as $value){} |
| ---- f4 ------ | -------------- |
| To gain access to a variable that is outside from the function we use the global keyword. True or False | True |
| $s = “variable”; function f(){ global $s; echo “function called ”; echo “$s”; } f(); function called function called variable function variable function called undefined variable: s | function called variable |
| Which of the following is not part of function for array manipulation Unset Destroy Explode Implode | Destroy |
| reverse a given string stringrev revstr strrev revstring | strrev |
| Same as include function except it includes the file only once. require_once require include include_once | include_once |
| Syntax for unset void unset (void $var) void unset ( mixed $var [, mixed $...] ) mixed unset (mixed unset) mixed unset (void $var) | void unset ( mixed $var [, mixed $...] ) |
| Syntax for require once require_once(filename.inc); filename(“require_once”); require_once(filename.php); require_once(“filename.inc”); | require_once(“filename.inc”); |
| Format character for day of the month without leading zeros m d z j | j |
| $x = rand(5,10);echo $x; What is the maximum value of the output? | 10 |
| Format character for English ordinal suffix for the day of the month, 2 characters C S D E | S |
| $x = ceil(10.01);echo $x; What is the output? | 11 |
| find the position of the first occurrence of a substring in a given string stringpos strpos posstr posstring | strpos |
| Format character for whether it’s a leap year | L |
| Same as require function except it includes the file only once. | require_once |
| Syntax for include include(filename.inc); filename(“include”); include(“filename.inc”); include(filename.php); | include(“filename.inc”); |