Coursera Answers

Building Web Applications in PHP | Week 7 Practice Quiz Answer

Building Web Applications in PHP Week 7 Practice Quiz Answer

Functions

Question 1)
Why should you use functions?

  • Organize your code
  • Break complex code into logical chunks
  • Avoid repetitive code
  • To make it harder for others to use your code

 

Question 2)
Which keyword defines a new function?

  • new functions
  • new
  • define
  • function

 

Question 3)
Return values are type-specific in php functions (a function only returns a value of a specified data type.)

  • True
  • False

 

Question 4)
What output does the following code produce?

function double($val){ $val = $val * 2; return $val; } $val = 15; $dval = double($val); echo “Value = $val Doubled = $dval”;</span >

  • Value = 15 Doubled = 15
  • Value = Doubled =
  • Value = 15 Doubled = 30</span >
  • Value = 30 Doubled = 30

 

Question 5)
Which keyword is used to use code from one php file into a different PHP file?

  • add
  • append
  • point
  • include

 

Question 6)
Which function prints out the internal configuration capabilities of your particular PHP installation?

  • phpinfo()
  • version()
  • info()
  • phpver()

 

Question 7)
Adding an ampersand ( & ) to a function parameter indicates that you are using call by [_____] for that parameter.

  • reference</span >

 

Question 8)
The keyword [_____] will expand the scope of a variable outside of its function.
  • global

 

Question 9)
The [_____] function is used to check if a function already exists or not.

  • function_exists</span >

 

Question 10)
It is common to use uppercase and/or long names for global variables to avoid confusion or mistaken reuse.

  • True
  • False