PHP quiz questions

PHP interview questions

  • 1.

    Can you extend a Final defined class?

    Answer:

    No, you cannot extend a Final defined class. A Final class or method declaration prevents child class or method overriding.

    View
  • 2.

    Which operator is used to check if two values are equal and of same data type?

    1. ==

    2. ===

    3. =

    4. !=

    Answer
  • 3.

    The if statement is used to execute some code only if a specified condition is true

    1. True

    2. False

    Answer
  • 4.

    How do you create an array in PHP?

    1. $cars = array("Volvo", "BMW", "Toyota");

    2. $cars = "Volvo", "BMW", "Toyota";

    3. $cars = array["Volvo", "BMW", "Toyota"];

    Answer
  • 5.

    In PHP, the only way to output text is with echo.

    1. True

    2. False

    Answer
  • 6.

    The setcookie() function must appear BEFORE the <html> tag.

    1. True

    2. False

    Answer
  • 7.

    Which one of these variables has an illegal name?

    1. $myVar

    2. $my-Var

    3. $my_Var

    Answer
  • 8.

    The die() and exit() functions do the exact same thing.

    1. True

    2. False

    Answer
  • 9.

    PHP can be run on Microsoft Windows IIS(Internet Information Server):

    1. True

    2. False

    Answer
  • 10.

    What is a correct way to add a comment in PHP?

    1. <!--...-->

    2. *\...\*

    3. <comment>...</comment>

    4. /*...*/

    Answer
  • 11.

    What is the correct way to add 1 to the $count variable?

    1. $count++;

    2. ++count

    3. count++;

    4. $count =+1

    Answer
  • 12.

    Which superglobal variable holds information about headers, paths, and script locations?

    1. $_SERVER

    2. $_GET

    3. $_SESSION

    4. $_GLOBALS

    Answer
  • 13.

    PHP allows you to send emails directly from a script

    1. True

    2. False

    Answer
  • 14.

    What is the correct way to open the file "time.txt" as readable?

    1. fopen("time.txt","r");

    2. fopen("time.txt","r+");

    3. open("time.txt");

    4. open("time.txt","read");

    Answer
  • 15.

    What is the correct way to create a function in PHP?

    1. create myFunction()

    2. function myFunction()

    3. new_function myFunction()

    Answer
  • 16.

    What is the correct way to include the file "time.inc" ?

    1. <?php include "time.inc"; ?>

    2. <?php include:"time.inc"; ?>

    3. <!-- include file="time.inc" -->

    4. <?php include file="time.inc"; ?>

    Answer
  • 17.

    Include files must have the file extension ".inc"

    1. True

    2. False

    Answer
  • 18.

    In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings:

    1. True

    2. False

    Answer
  • 19.

    When using the POST method, variables are displayed in the URL:

    1. True

    2. False

    Answer
  • 20.

    How do you get information from a form that is submitted using the "get" method?

    1. Request.Form;

    2. Request.QueryString;

    3. $_GET[];

    Answer

© 2017 QuizBucket.org