PHP Programming Quiz

30 Questions | Total Attempts: 1862

SettingsSettingsSettings
Please wait...
PHP Programming Quiz

Republic Polytechnic Students: You need to set aside 60 mins to complete this quiz. There will be 30 questions in the quiz; the purpose is to test your ability to apply your problem solving and PHP programming skills.


Questions and Answers
  • 1. 
    Rearrange these steps in the correct order. 1. Connect to Database Server2. Close database connection3. Execute SQL query4. Retrieve HTML form data5. Build SQL statement
    • A. 

      1,4,3,2,5

    • B. 

      5,4,3,2,1

    • C. 

      3,4,5,2,1

    • D. 

      1,4,5,3,2

    • E. 

      4,5,3,1,2

  • 2. 
    Complete the PHP statement to retrieve data from a FORM with an input named ‘weight’ that is submitted using the “post” method.$myData = __________ ;
  • 3. 
    Consider the following scenario and answer the related questions:• XAMPP is in the c:\xampp\ folder of your local machine• The c:\xampp\htdocs\myProject\ folder contains a HTML document called postItem.htmlWhat is the URL to display postItem.html in your browser in the same machine?____________________________________________________
  • 4. 
    Retrieve data from a FORM with an input named ‘distance’ that is submitted using the “post” method. Write ONE PHP statement to store the data in variable $gap.
  • 5. 
    The following 2 lines are part of a HTML document, fill in the blank: 
  • 6. 
    The following 2 lines are part of a HTML document, fill in the blank: 
  • 7. 
    The following lines are part of a HTML document for login screen:Fill in the blank so that user will not see the password being typed in:
  • 8. 
    Write ONE PHP statement to show this output using variable $gap (need to pay attention to spacing in the output):
  • 9. 
  • 10. 
    Complete the while-loop that terminates (stops) when $myData reaches 33 (not inclusive).
  • 11. 
    Examine the loop below and write down the value of $x printed on the screen.Value of $x:
  • 12. 
    Examine the loop below and write down the value of $y printed on the screen.Value of $y:
  • 13. 
    What is the return type of strcmp() function?
  • 14. 
    How many mandatory arguments (parameters) does fopen() function require?
  • 15. 
    What is the required data type of the first argument (parameter) of fopen() function?
  • 16. 
    What is the name of the PHP code that is executed when the Calculate button of this form is pressed?Answer:
  • 17. 
    Complete the code according to comment provided: Answer:
  • 18. 
    Complete the PHP statement to retrieve data from a FORM with an input named ‘durationInHour’ that is submitted using the “post” method; convert it to seconds.$ durationInSeconds = $_POST['_______________;
  • 19. 
    The ‘c203project’ database has a table called ‘keyContacts’, with the following schema:What is the primary key field name?
  • 20. 
    The ‘c203project’ database has a table called ‘keyContacts’, with the following schema:Complete the PHP statement to store the SQL statement in variable $query1 - Inserting ONE record into the table. _________________________ (contact_name, phone, email) VALUES ($name, $contactno, $eMail)";
  • 21. 
    The ‘c203project’ database has a table called ‘keyContacts’, with the following schema:Complete the PHP statement to store the SQL statement in variable $queryCount - Find out total number of contacts.___________________________________________  FROM keyContacts";
  • 22. 
    The ‘c203project’ database is residing in server “sit.rp.sg”; it has a table called ‘keyContacts’. Complete the PHP statement to connect to the MySQL Server using user “admin” with password “pWd!”.$conn = __________________________________________________;
  • 23. 
    Complete the PHP statement to execute the SQL query in variable $selectStr. Database connection is stored in variable $conn.$allRows = ______________________________;
  • 24. 
    What is the result of execution of a failed INSERT SQL query?
    • A. 

      0 (zero)

    • B. 

      1

    • C. 

      True

    • D. 

      False

    • E. 

      Result object

  • 25. 
    What is the result of execution of a successful SELECT SQL query?
    • A. 

      0 (zero)

    • B. 

      1

    • C. 

      True

    • D. 

      False

    • E. 

      Result object