Professional Test For PHP Web Developers!

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Ksj786
K
Ksj786
Community Contributor
Quizzes Created: 1 | Total Attempts: 7,485
Questions: 15 | Attempts: 7,485

SettingsSettingsSettings
Professional Test For PHP Web Developers! - Quiz

What does a PHP web developer do? PHP is a general-purpose programming language that was originally designed for web development. PHP is being used by more developers, especially in the world of freelancers. It is used mostly because of the cost matter. PHP developers create programs, applications, and web sites, and PHP is known for its web development and business application. Take this impressive quiz to see what you know about web developers.


Questions and Answers
  • 1. 

    What will be printed?if ('2' == '02') { echo 'true';} else { echo 'false';}

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The given code will print "true". This is because the comparison operator used is the loose equality operator (==), which does not consider the data types of the operands. In this case, both '2' and '02' are considered equal because they have the same characters. Therefore, the condition ('2' == '02') evaluates to true, and the code block inside the if statement is executed, resulting in the output "true".

    Rate this question:

  • 2. 

    Which of the following is NOT a valid pHP comparison operator?

    • A.

      !=

    • B.

      >=

    • C.

    • D.

    • E.

      ===

    Correct Answer
    C.
    Explanation
    The comparison operator "===" is a valid PHP comparison operator. It is used to compare both the value and the type of two variables. The "!=" operator is used to check if two values are not equal, while the ">=" operator is used to check if the left operand is greater than or equal to the right operand. Therefore, the correct answer is ">=".

    Rate this question:

  • 3. 

    What will be printed?$a = array( null => 'a', true => 'b', false => 'c', 0 => 'd', 1 => 'e', '' => 'f');echo count($a), "\n";

    • A.

      2

    • B.

      3

    • C.

      4

    • D.

      5

    • E.

      6

    Correct Answer
    B. 3
    Explanation
    Keys will be converted like this: null to '' (empty string), true to 1, false to 0

    Rate this question:

  • 4. 

    What gets printed?class MyException extends Exception {}try { throw new MyException('Oops!');} catch (Exception $e) { echo "Caught Exception\n";} catch (MyException $e) { echo "Caught MyException\n";}

    • A.

      Caught Exception

    • B.

      Caught MyException

    Correct Answer
    A. Caught Exception
    Explanation
    The first catch will match because MyException is a subclass of Exception, so the second catch is unreachable

    Rate this question:

  • 5. 

    What will be printed?$a = array();if ($a[1]) null;echo count($a), "\n";

    • A.

      0

    • B.

      1

    • C.

      2

    • D.

      This code wont compile

    Correct Answer
    A. 0
    Explanation
    checking value in if() does not create an array element

    Rate this question:

  • 6. 

    What gets printed?$str = 'a\\b\n'; echo $str;

    • A.

      Ab(newline)

    • B.

      A\b(newline)

    • C.

      A\b\n

    • D.

      A\\b(newline)

    • E.

      A\\b\n

    Correct Answer
    C. A\b\n
    Explanation
    \\ is a special case in single-quoted string literals, which gives a single \, \n is not interpolated in single-quoted string literals

    Rate this question:

  • 7. 

    What is a correct way of defining constants in pHP

    • A.

      Constant $var

    • B.

      Const $var

    • C.

      Constant ($var)

    • D.

      Define("Constant");

    Correct Answer
    D. Define("Constant");
    Explanation
    The correct way of defining constants in PHP is by using the "define" function followed by the constant name in quotes. This function allows us to define a constant with a specific value, which cannot be changed throughout the execution of the script.

    Rate this question:

  • 8. 

    Which function will you use to convert an HTML page into a format that can be saved in database conveniently

    • A.

      Stripslashes()

    • B.

      Htmlentities()

    • C.

      Htmlspecialchars()

    Correct Answer
    B. Htmlentities()
    Explanation
    The htmlentities() function is used to convert special characters in an HTML page into their corresponding HTML entities. By using this function, any special characters in the HTML code will be converted into a format that can be safely stored in a database. This ensures that the HTML code is properly encoded and can be easily retrieved and displayed without causing any issues or conflicts with the database.

    Rate this question:

  • 9. 

    Which of the following functions will be used to create a CURL sessions

    • A.

      Curl_exec()

    • B.

      Curl_opt()

    • C.

      Curl_init()

    • D.

      Curl_setopt()

    Correct Answer
    C. Curl_init()
    Explanation
    The function curl_init() is used to initialize a CURL session. This function returns a CURL handle, which is then used as the parameter for other CURL functions like curl_setopt() to set various options for the session. Once the session is initialized and options are set, the session can be executed using curl_exec() to perform the desired tasks like making HTTP requests and retrieving data from a remote server. Therefore, curl_init() is the correct function to create a CURL session.

    Rate this question:

  • 10. 

    Which of the following is true about GET & POST methods

    • A.

      GET will not show variables in URL of address bar of browser

    • B.

      POST variables can not be accessed by $_REQUEST[] Server side array

    • C.

      Using POST, you can hide form data from being viewed on address bar or browser

    Correct Answer
    C. Using POST, you can hide form data from being viewed on address bar or browser
    Explanation
    The POST method allows for the submission of form data without displaying it in the address bar or browser. This is useful when dealing with sensitive information that should not be visible to the user or easily accessible. With the GET method, the variables are displayed in the URL of the address bar, making them visible and potentially accessible to anyone who sees the URL. Additionally, the $_REQUEST[] server-side array can access both GET and POST variables, so the statement that POST variables cannot be accessed by $_REQUEST[] is incorrect.

    Rate this question:

  • 11. 

    Which of following statements will be used to fetch SINGLE record  from a MySql resultset

    • A.

      Mysql_connect

    • B.

      Mysql_query

    • C.

      Mysql_fetch_array

    • D.

      Mysql_fetch_row

    Correct Answer
    D. Mysql_fetch_row
    Explanation
    The function mysql_fetch_row is used to fetch a single record from a MySQL resultset. It returns an indexed array that contains the values of the fetched row. This function is commonly used when the resultset contains a large number of rows and the memory usage needs to be optimized.

    Rate this question:

  • 12. 

    What is correct syntax of connecting to a MySql database

    • A.

      Mysql_connect($username,$password)

    • B.

      Connect_mysql($username,$password)

    • C.

      Mysql_connect("localhost",$username,$password)

    Correct Answer
    C. Mysql_connect("localhost",$username,$password)
    Explanation
    The correct syntax for connecting to a MySql database is "mysql_connect("localhost",$username,$password)". This syntax specifies the host as "localhost" and includes the variables $username and $password, which hold the login credentials for the database.

    Rate this question:

  • 13. 

    Which of the following functions MUST be called AFTER using mysql_connect() function

    • A.

      Mysql_query

    • B.

      Mysql_fetch_array

    • C.

      Mysql_select_db

    • D.

      Mysql_fetch_row

    Correct Answer
    C. Mysql_select_db
    Explanation
    The function mysql_select_db must be called after using mysql_connect() because it is used to select a specific database to work with. Once the connection to the MySQL server is established using mysql_connect(), this function is necessary to specify the database that will be accessed for subsequent queries and operations.

    Rate this question:

  • 14. 

    What gets printed?<?php$RESULT = 11 + 011 + 0x11;echo "$RESULT";?>

    • A.

      11

    • B.

      22

    • C.

      33

    • D.

      37

    • E.

      39

    Correct Answer
    D. 37
    Explanation
    A decimal plus an octal plus a hex number. 11 + 9 + 17 = 37

    Rate this question:

  • 15. 

    What will be the value of $var below?$var = true ? '1' : false ? '2' : '3';

    • A.

      1

    • B.

      2

    • C.

      3

    Correct Answer
    B. 2
    Explanation
    In the given code, the value of $var is determined using the ternary operator. The first condition is true, so the value '1' is assigned to $var. However, this is followed by another ternary operator where the condition is false. In this case, the value '2' is assigned to $var. Therefore, the final value of $var is '2'.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Nov 16, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 16, 2011
    Quiz Created by
    Ksj786
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.