QUESTION 16 What does the array $soups look like after this code runs? $soups =
ID: 3600338 • Letter: Q
Question
QUESTION 16
What does the array $soups look like after this code runs?
$soups = array("tomato", "onion", "cheese", "chowder");
$c = array_pop($soups);
array("onion", "cheese", "chowder")
array("tomato", "onion", "cheese")
array("tomato", "onion", "chowder")
array("tomato", "cheese", "chowder")
QUESTION 17
"A multidimensional indexed array has two sets of brackets, one for the row and one for the column."
True
False
QUESTION 18
"If a value exists in an array the in_array() function returns 'true', otherwise it returns false."
True
False
QUESTION 19
What does the variable $y hold after these lines execute?
$x = "person5@xyz.com";
$y = strpos($x, "6");
6 isn't present in $x, so none of the other answers are correct
5
6
7
10
QUESTION 20
What prints?
$soups = array("tomato", "onion", "cheese", "chowder");
$c = array_pop($soups);
echo $c;
tomato;
onion;
cheese;
chowder
QUESTIOn 21
The ____ function lets you add or remove elements anywhere else in the array.
array_add()
array_split()
array_splice()
array_values()
QUESTION 22
To remove leading and trailing spaces from a string you would use ____.
ltrim()
trim()
rtrim()
lrtrim()
QUESTION 23
To capitalize the first character of a string use ____.
str_first()
first()
ucfirst()
uc_initial()
QUESTION 24
The unset() function removes array elements.
True
False
QUESTION 25
You use the ____ function to return a portion of an array and assign it to another array.
array_slice()
array_set()
array_assign()
array_key()
QUESTION 26
What is printed?
$str1 = "beets";
echo 'Eat more $str1';
Eat more $str1
Eat more beets
QUESTION 27
"The primary use of the include and require statements is to reuse content on multiple web pages by allowing you to insert the content of an external file, called an include file, in your PHP scripts."
True
False
QUESTION 28
"In PHP, you must declare a global variable with the global keyword inside a function definition for the variable to be available within the scope of that function."
True
False
QUESTION 29
What is a sticky form?
a HTML form that is cached on the user's computer and hidden from the user in their browser until it is formally requested.
a form that will not be closed in the user's browser unless it has been submitted first.
a HTML form that retains its values between postbacks.
none of these
QUESTION 30
Which of the following is true of using printf()? Choose 3.
%0.2f will round the floating point number to 2 decimal places when substituted
%5s will right-justify a short string when substituted
%-5s will left-justify a short string when substituted
%-5s will right-justify a short string when substituted
array("onion", "cheese", "chowder")
array("tomato", "onion", "cheese")
array("tomato", "onion", "chowder")
array("tomato", "cheese", "chowder")
Explanation / Answer
Q 16. Since array_pop() function delete the last element of an array. so the array $soups look like after the execution of this method : array("tomato", "onion", "cheese").
Q17. yes, it will be true.
Q18. Yes it is also true because
The in_array() function searches an array for a specific value and it returns true if an element found otherwise returns false.
Q 19. true option will be : 6 isn't present in $x, so none of the other answers are correct because The strpos() function finds the position of the first occurrence of a string inside another string.
Q 20. same as question number 16 output will be :chowder. because The array_pop() function deletes the last element of an array.
Q 21. The array_splice() function removes selected elements from an array and replaces it with new elements. The function also returns an array with the removed elements.
Q 22. Correct output: trim() because the trim() function removes whitespace and other predefined characters from both sides of a string.
Q 23. The ucfirst() function converts the first character of a string to uppercase.
Q 24. false because the unset() function destroys a given variable.
Q 25. The array_slice() function returns selected parts of an array.
Q 26. the output will be: Eat more $str1.
Q 27. true but
The include and require statements are identical, except upon failure:
So, if you want the execution to go on and show users the output, even if the include file is missing, use the include statement. Otherwise, PHP application coding, always uses the require statement to include a key file to the flow of execution. This will help avoid compromising your application's security and integrity, just in-case one key file is accidentally missing.
Q 28. true because
The global keyword is used to access a global variable from within a function.
To do this, use the global keyword before the variables (inside the function). and PHP also stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable. This array is also accessible from within functions and can be used to update global variables directly.
Q 29.true option: a form that will not be closed in the user's browser unless it has been submitted first. because A sticky form is simply a standard HTML form that remembers how you filled it out. This is a particularly nice feature for end users, especially if you are requiring them to resubmit a form (for instance, after filling it out incorrectly in the first place).
Q 30. %0.2f will round the floating point number to 2 decimal places when substituted.
%-5s will right-justify a short string when substituted.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.