PHP Level 1

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 Johnkawakami
J
Johnkawakami
Community Contributor
Quizzes Created: 3 | Total Attempts: 3,349
Questions: 10 | Attempts: 853

SettingsSettingsSettings
PHP Quizzes & Trivia

This tests your basic understanding of PHP software development, including general programming concepts like recursion, functions, and objects. Passing the test indicates that you recognize and understand basic computer programming, beyond copying data from forms into page layouts, and understand the terminology related with basic computer programming.


Questions and Answers
  • 1. 

    Which of the following doesn't look like pHP code?

    • A.

      $a = 10;

    • B.

      If ($this->isComplete()) echo "finished";

    • C.

      Printf('%d',10);

    • D.

      Document.writeln(requestObject.parameter("id"))

    • E.

      Echo $switch ? $switch : '';

    Correct Answer
    D. Document.writeln(requestObject.parameter("id"))
    Explanation
    D is a mishmash of Javascript and VBScript, and uses the dot notation for objects. PHP uses the arrow notation.

    Rate this question:

  • 2. 

    Which of the following is a function call.

    • A.

      Fib(5)

    • B.

      ( $i > LAST_ITEM )

    • C.

      $n = 100;

    • D.

      5 + 10

    • E.

      Function total( $x, $y, $z ) { return $x + $y + $z; }

    Correct Answer
    A. Fib(5)
    Explanation
    The function is fib(). Choice E is incorrect, because it's a function definition. A "call" is when you use a function.

    Rate this question:

  • 3. 

    Which of the following is an example of the use of an arithmetic operator?

    • A.

      While (true) { echo "x"; }

    • B.

      F(10)

    • C.

      $a + $b

    • D.

      $n = array( 1, 3, 9, 27 );

    • E.

      Print "10 - 5 = 5";

    Correct Answer
    C. $a + $b
    Explanation
    In C, the "+" is an arithmetic operator. The other operator, in D, is =, which is an assignment operator.

    Rate this question:

  • 4. 

    Which of the following is not a supported syntax to call a method on an object or a class?

    • A.

      MyClass::myMethod($x);

    • B.

      $obj->myMethod($x);

    • C.

      $obj.myMethod($x);

    • D.

      $n = new MyClass(10)->myMethod($x);

    • E.

      $obj->$funcName($parameter);

    Correct Answer
    C. $obj.myMethod($x);
    Explanation
    C - the dot notation is not supported. Choice E is legitimate.

    Rate this question:

  • 5. 

    Here is a dense, faulty bit of pHP code that just won't work.  You know, the kind your coworker wrote (lulz).  All of the following reasons, except one, are reasons why the code isn't working.$a = $POST['name'];print 'Hello $a';include('db_layer.inc.php'); // connects to db$db = new db();$db->insert("insert into foobar (name) $a");?>

    • A.

      The POST variable name is wrong.

    • B.

      The input is not escaped and quoted before being inserted into the query.

    • C.

      The "Hello" message was quoted incorrectly, and won't display the arugment.

    • D.

      The input is not sanitized before printing to the browser.

    • E.

      An HTML tag is not closed.

    Correct Answer
    D. The input is not sanitized before printing to the browser.
    Explanation
    D - while not sanitizing input is punishable by humiliation, it won't prevent the code from running.

    Rate this question:

  • 6. 

    You have a large array of names, sorted randomly, and you need to extract all the names that start with the letter "M". What kind of magical pHP incantations will appear in your code?

    • A.

      For(....), if (....) { $a[] = ... }

    • B.

      Foreach(....) preg_match

    • C.

      Map( function () = '....' ); substr(); array_push();

    • D.

      Grep(); keys(); unshift()

    • E.

      Array(... select from( where(...) );

    Correct Answer
    C. Map( function () = '....' ); substr(); array_push();
    Explanation
    C will produce the shortest code. It's esoteric, but easy to understand once you understand it. D and E were red herrings.

    Rate this question:

  • 7. 

    Your client says they want to build a clone of Craigslist or Kijiji.  You think they're nuts, but they convince you they can do it.  Around how many data tables do you think it will take?

    • A.

      5

    • B.

      10

    • C.

      50

    • D.

      300

    • E.

      2000

    Correct Answer(s)
    C. 50
    D. 300
    Explanation
    It's a pretty small application, despite it's popularity. C or D could be correct answers.

    Rate this question:

  • 8. 

    You whipped up a little MySQL database backed website, and now the traffic has exploded.  The server is slowing down.  Listed are some ways you can reduce the load.  Which will give you the least gain?

    • A.

      Analyze your queries, and add indexes to tables to speed them up.

    • B.

      Add an object cache like APC or Zend.

    • C.

      Generate a static home page, and for some internal pages.

    • D.

      Move the database to it's own machine and connect to it via TCP/IP

    • E.

      Use memcached to store serialized query results, and use it as a result cache.

    Correct Answer
    B. Add an object cache like APC or Zend.
    Explanation
    B - the bottleneck is the database and the fact it goes to disk to get results. An object cache only helps avoid compilation, but doesn't address the DB speed issue. Separating the database to its own machine is also not likely to help much normally, but, simply doubling the number of CPUs will definitely gain performance on heavily loaded servers.

    Rate this question:

  • 9. 

    Computer scientists like recursion.  In the real world, especially on multi-user situations like pHP faces, recursion isn't so popular.  There are many reasons why people forego recursion.  Which of the following is usually not a reason.

    • A.

      Function calls are expensive.

    • B.

      Function call stack can run out of space.

    • C.

      Consumes lots of memory.

    • D.

      Difficult to understand.

    • E.

      It's easier to use arrays and indices.

    Correct Answer
    E. It's easier to use arrays and indices.
    Explanation
    If it's easily solved by recursion, it's rarely every easier to solve it with arrays.

    Rate this question:

  • 10. 

    pHP runs on many platforms, mainly Unixes.  When you run code developed on a Snix machine and move it over to a Windows server, which issue below is not likely to be a problem.

    • A.

      Case folding causes similarly named files to overwrite another.

    • B.

      Calling mail() fails.

    • C.

      Executing code that calls OLE fails.

    • D.

      File paths stop working.

    • E.

      Missing or not-ported extensions.

    Correct Answer
    C. Executing code that calls OLE fails.
    Explanation
    C is a red herring. OLE is a Windows technology.

    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
  • Mar 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Oct 14, 2009
    Quiz Created by
    Johnkawakami
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.