PHP Tutorials

Top 10 PHP Interview Questions

PHP-interview-questionGoing for an interview is something many people dread.  However, there are resources and tools that can help interviewees prepare for the interview. Going for a PHP interviews requires vast knowledge. However, this guide is going to present some of the trickiest questions asked in PHP interviews.

  • What is PHP? PHP is a backward ellipsis for the word PHP Hypertext Preprocessor. It is a vastly used scripting language and it is open sources. In addition, it enables execution of scripts on servers
  • What are the differences between print and echo? In terms of parameters, print allows only one parameter, while echo accepts multiple parameters if it is not used with parentheses. When it comes to return value, print constantly brings back 1(integer). On the other hand, echo returns no value. With print, its syntax is, int print (string $arg), while echo’s is, void echo (string $arg1 [, string $…]). Lastly, print in PHP is a language construct and not a function. It may seem confusing because it may behave like a function because it returns a value. On the other hand, echo is completely a language construct and not a function.
  • How does interaction of PHP and JavaScript take place? First, JavaScript and PHP cannot interact directly. This is because JavaScript is a silent side language, while PHP is a server language. These two languages can exchange variables; this is because PHP can generate JavaScript codes to be implemented on the browser. In addition, through the URL, it is possible to pass back certain variables to PHP.
  • What is the actual version of PHP that is used? Version 5 is the used version of PHP that is used.
  • How is does someone compare objects in PHP5? When comparing two items on PHP5, the ‘==’ operator is used. This is for testing two objects from the same class, with similar attributes and equal values. This can be tested if two objects have the same instances and if they are from the same class. This is possible using the identity operator ‘==’.
  • What is the difference between splitting and exploding? Splitting entails using a regular expression to divide a string into an array. On the other hand, exploding divides a string into an array by use of a string.
  • What is the difference between $string and $str? The strstr utility searches for $str in $string. If strstr finds the string, it will return it from its source. In actual sense, the main difference between strstr and stistr is case sensitivity. Strstr mulls over the case difference, where as stristr, disregard the case difference.
  • What the difference is there between require and include? These two functions calculate the specific files and generally carry out similar functions. However, the difference comes in the way the handle failure. In the case of failure to find the file path, require () ceases the program and displays a fatal error. In the case of include (), it gives a warning message and proceeds running the program and does not terminate the program.
  • What are the differences between the POST and GET methods? POST parameters are not saved in history, whereas GET parameters are stored in the browser history because they are integrated into the URL. User cannot bookmark Post, but can bookmark Get. In addition, Post cannot be cached, while users can cache Get. When it comes to restrictions, Post has no restrictions, but there are some restrictions on Get and this is mainly because form data is in the URL and there is a restriction of URL length, depending on the site. Post is difficult to hack, while Get is much easier to hack. Post is easier and safer to use, especially when sending sensitive data and passwords. On the other hand, using Get to send sensitive data is risky. When it comes to visibility, Post is more difficult to see because the variables are not shown on the URL, but I the case of Get, everyone can view it, as it is displayed on the address bar of the browser. In addition, there is a limit on the amount of data and information that can be sent.
  • How can and infinite execution time be set for a PHP script? This is done by setting the infinite time limit at the commencement of the script (set_time_limit(0)) this is how the script should look like, for an infinite time limit. This can also be specified in the php.ini file.

Some more questions include:

  • Differences between the 42 and x42 characters
  • What is the meaning of MVC
  • Does PHP support multiple inherences?
  • What function can be used to display the sent headers?

These questions and many more could appear in an interview and each is fundamental to testing applicant knowledge in PHP.

Leave a Reply

Your email address will not be published. Required fields are marked *