Esquire Theme by Matthew Buchanan
Social icons by Tim van Damme

25

May

Recruiter asked me to take an ONLINE assessment test in PHP

Today I took an ONLINE assessment test in PHP from Proveit2.com(Kenexa Prove It! Skills Assessments). All questions were multiple choice questions with only one possible correct answer. I enjoy taking those assessments exams because it is another way to learn. On this post, I will try to comment on the test (what I can remember of it).

in_array()

    This function checks if a value exists on an array. If it finds a value, it returns boolean TRUE. If nothing is found, it returns boolean FALSE. The function itself is self-explanatory. The way that I like to remember this function is by asking myself the question “Is it in_array()?

PHP Magic Quotes

    Magic quotes, if enabled, will escape backslashes, double quotes and single quotes automatically. I know about Magic Quotes because I have been studying for the Zend PHP Certification; one of their requirements is that magic_quotes_gpc must be disabled. If enabled, Magic Quotes will automatically escape any incoming data like form submission. Magic Quotes is DEPRECATED according to the PHP manual. Another question on the exam had to do with how to strip out quotes. I am pretty sure that I got that one wrong because I was confused between the stripslashes() and addslashes() functions. The former is used to un-quote a quoted string while addslashes() will function the same way as PHP Magic Quotes.

ucwords()

    There can be no doubt as to what this function does. I mean, UC. stands for UpperCase and the plural of words gave it away that it had to uppercase more than one letter. For what I can remember, the tricky part of this question was the other functions in the multiple choice answers. They looked kind of similar but I shot for what seemed more appropriate. In all honest, I didn’t quite remember this one. It was a guess. Unlike strtoupper() that is used to uppercase an entire string, ucwords() will uppercase the first letter of each given word.

session_start() headers

    session_start() will initialize session data and send out several HTTP headers depending on the configuration. session_cache_limiter() can be used to control the following major headers Expires, Pragma and Content-Type. There are several other headers as well. The test concentrated in the above headers. For example, a session can be expired by sending a Expires header to the client causing him/her to log out. With the header Cache-Control one can allow/disallow the client to save information.

session_name()

   The session can be renamed using session_name() but it must be called before starting session_start(). Basically, you can rename a session and then expire the old one. I think that renaming it can avoid conflict. I never needed to rename a session so I am not sure how this would be useful.

lcfirst()

   Makes a string’s first character lowercase unlike strtolower() which lowercase the entire string. Again, the function is self-explanatory. lcfirst() stand for lower-case-only-first-character.

namespace identifier

    I have no experience with namespaces. But from looking at the answers, I could tell that this causes an error or warning. I took a good guess on this one. After the exam, I looked it up on the Internet and fair enough it does cause an error. But I do have to research on this one. All multiple choices answers had errors or warnings.

goto

   They gave a class with a method called goto. This would never work because goto is a reserved word. It’s a well known reserved word.

extension_loaded()

   It is possible to find out which extensions are loaded with using this function. However, I prefer phpinfo() because not only do you get to see your extensions but also almost every other important information.

REST

   This question asked what REST returned. It is XML, JSON.

constant table

    A constant table is a table that is:

  1. empty.
  2. has 1 row.
  3. a table that is used with the WHERE clause on an UNIQUE index or PRIMARY KEY where all INDEX parts are used in constant expressions and the index parts are defined as NOT NULL.

array_unique()

    This function will look for all duplicates and return a new array without any duplicated.

xml_parse_into_struct()

    This function is very much used. Parse XML data into an array structure.

mysql_field_seek()

    I never used it but it’s kind logical to think that it will seek a field in an array. Why? Well, mysql returns an array; arrays work with offsets. So logically this function had to seek an offset field. Now what it does with it or what not. That I have to look it up later.

number_format()

   This function will take a number and place commas where applies. So for example. If I give it 124987234, it should return 124,987,234.

round()

   In the exam, they wanted to know how to round down a number. In the multiple choice answers they had all kind of functions like round_down() and roundDown() so it was confusing. I chose round() because it was what I knew. In fact, round() will round it up or down. To my knowledge, there is no other function to do the same thing.

SOAP __doRequest

   The question had to do with what method performs a request when using SOAP. the answer was __doRequest. This was another good guess.

E_NOTICE

   This predefined constant will return run-time errors only. The function error_reporting() takes logical operators to return errors. So you can return E_NOTICE & E_ALL among other errors. This was easy!

substr() and strpos()

   I used a little bit of common sense on this question. substr() takes 3 parameters. That much I knew. So one of the answers was already cut out. Also the last 2 parameters of substr() takes only numbers. The second parameter is for position and the third one for length. With strpost(), we can can find the position. So with that, I ruled out another answer that had strpost() for length. With the 2 answers remaining, the length count for “true” could only be 4. I went for that answer.

date()

   This question shouldn’t have been there in the first place. The reason why I say this is because it’s a little too much to expect that a person can remember all the possible variations of lowercase and uppercase letters that when put together can give you the date specified. One thing I kind of noticed from working with date() is that usually lowercase letters represent numbers while uppercase letters represent strings. So I kind of took an estimated guess on this one.

strtotime() and idate()

    strtotime formats a date into number seconds. This is what we call UNIX timestamp format. With idate(), you can take an UNIX timestamp and return an integer number. I never used UNIX timestamps let alone idate. So I probably got this one wrong.

modulus operator

    There was a question with a modulus operator. Basically, they gave two integers and they asked for the result modulus of it. The result was 6. The modulus operator gives the reminder.

error control @ operator

    This operator suppresses any errors that may occur. So for example, in the test they had a variable inside of a string but that variable did not exist. it hadn’t been declared and set. Without the error control operator, it would have returned an error instead. But with the operator it suppresses the error and still prints part of the expression.

array_pop() and implode()

array_pop() was a tricky one because I never used it. I didn’t know it existed. So I took a guess on this one. But array_pop() will pop the last element of an array. implode() will join elements.