25 PHP Interview Questions – Can You Answer Them All?
Let’s take a look at some tips!
Tip 1 •“One of the most important things I watch out is the creativity of the person I interview. I try to catch the developers who are constantly learning new things, they are driven by curiosity and also very creative, not just in problem solving but in general too. I mostly ask about PHP and PostgreSQL (I use this combo most of the time).” ~ Laszlo Levente Mári, ex-Googler
Tip 2 •“During the interview of a potential candidate I am aiming to understand how updated they are with the new language features as well as their level of understanding of basic operations. In my opinion, this will define how good a developer will become in the future.” ~Agli Pançi, Lead Developer
Tip 3 •“I would expect from a junior developer is that know the basics of programing and how apply these basics to php. I wouldn’t expect that a Junior Developer knows the name of certain functions or complex terms on PHP.” ~Oscar Andrés Monroy, Senior PHP Developer
Now, the interview questions…
Question #1 •What’s the difference between the include() and require() functions?
Question #2 •How can we get the IP address of the client?
Question #3 •What’s the difference between unset() and unlink() ?
Question #4 •What is the output of the following code: $a = '1'; $b = &$a; $b = "2$b"; echo $a.", ".$b;
Question #5 •What are the main error types in PHP and how do they differ?
Question #6 •What is the difference between GET and POST?
Question #7 •How can you enable error reporting in PHP?
Question #8 •What are Traits?
Question #9 •Can the value of a constant change during the script’s execution?
Question #10 •Can you extend a Final defined class?
Question #11 •What are the __construct() and __destruct() methods in a PHP class?
Question #12 •How we can get the number of elements in an array?
Question #13 •How would you declare a function that receives one parameter name hello?
Question #14 •The value of the variable input is a string 1,2,3,4,5,6,7. How would you get the sum of the integers contained inside input?
Question #15 •Suppose you receive a form submitted by a post to subscribe to a newsletter. This form has only one field, an input text field named email. How would you validate whether the field is empty? Print a message "The email cannot be empty." in this case.
Question #16 •Suppose that you have to implement a class named Dragonball. This class must have an attribute named ballCount (which starts from 0) and a method iFoundaBall. When iFoundaBall is called, ballCount is increased by one. If the value of ballCount is equal to seven, then the message “You can ask your wish.” is printed, and ballCount is reset to 0. How would you implement this class?
Question #17 •What are the 3 scope levels available in PHP and how would you define them?
Question #18 •What are getters and setters and why are they important?
Question #19 •What does MVC stand for and what does each component do?
Question #20 •How does one prevent the following Warning ‘Warning: Cannot modify header information – headers already sent’ and why does it occur in the first place?
Question #21 •What are SQL Injections, how do you prevent them and what are the best practices?
Question #22 •What does the following code output? $i = 016; echo $i / 2;
Question #23 •Why would you use === instead of ==?
Question #24 •What are PSRs? Choose 1 and briefly describe it.
Question #25 •What PSR Standards do you follow? Why would you follow a PSR standard?
Question #26 •Do you use Composer? If yes, what benefits have you found in it?
More to think about…
Extra PHP Interview Practice Questions •What’s the difference between using mysql_ functions and PDO? •Describe how inheritance works with PHP. •Do you know what the PHP-FIG is? Describe it, describe the PSRs you know. •What classes would you create to build a basic Twitter-style status system with OOP? •What frameworks are you experienced in? •What frameworks do you prefer? Why? •Thoughts / experience with unit testing?
Exercise •Build the Twitter style status system mentioned above using PHP (it doesn’t have to run or be error-free). This should be MVP and take less than 30 minutes.
What Else to Brush Up On Our PHP interview questions here aren’t all-encompassing. Here are some additional concepts that our mentors think may be helpful for you brush up: • Using htmlspecialchars namespaces and short hand array styles [] • How to optimize code & how to pass user supplied data to SQL to avoid injection.
Good Luck to Your Interview!! For answers and more tutorials: https://www.codementor.io/php/tutorial/php-interview- questions-sample-answers

25 php interview questions – codementor

  • 1.
    25 PHP Interview Questions– Can You Answer Them All?
  • 2.
    Let’s take alook at some tips!
  • 3.
    Tip 1 •“One ofthe most important things I watch out is the creativity of the person I interview. I try to catch the developers who are constantly learning new things, they are driven by curiosity and also very creative, not just in problem solving but in general too. I mostly ask about PHP and PostgreSQL (I use this combo most of the time).” ~ Laszlo Levente Mári, ex-Googler
  • 4.
    Tip 2 •“During theinterview of a potential candidate I am aiming to understand how updated they are with the new language features as well as their level of understanding of basic operations. In my opinion, this will define how good a developer will become in the future.” ~Agli Pançi, Lead Developer
  • 5.
    Tip 3 •“I wouldexpect from a junior developer is that know the basics of programing and how apply these basics to php. I wouldn’t expect that a Junior Developer knows the name of certain functions or complex terms on PHP.” ~Oscar Andrés Monroy, Senior PHP Developer
  • 6.
    Now, the interviewquestions…
  • 7.
    Question #1 •What’s thedifference between the include() and require() functions?
  • 8.
    Question #2 •How canwe get the IP address of the client?
  • 9.
    Question #3 •What’s thedifference between unset() and unlink() ?
  • 10.
    Question #4 •What isthe output of the following code: $a = '1'; $b = &$a; $b = "2$b"; echo $a.", ".$b;
  • 11.
    Question #5 •What arethe main error types in PHP and how do they differ?
  • 12.
    Question #6 •What isthe difference between GET and POST?
  • 13.
    Question #7 •How canyou enable error reporting in PHP?
  • 14.
  • 15.
    Question #9 •Can thevalue of a constant change during the script’s execution?
  • 16.
    Question #10 •Can youextend a Final defined class?
  • 17.
    Question #11 •What arethe __construct() and __destruct() methods in a PHP class?
  • 18.
    Question #12 •How wecan get the number of elements in an array?
  • 19.
    Question #13 •How wouldyou declare a function that receives one parameter name hello?
  • 20.
    Question #14 •The valueof the variable input is a string 1,2,3,4,5,6,7. How would you get the sum of the integers contained inside input?
  • 21.
    Question #15 •Suppose youreceive a form submitted by a post to subscribe to a newsletter. This form has only one field, an input text field named email. How would you validate whether the field is empty? Print a message "The email cannot be empty." in this case.
  • 22.
    Question #16 •Suppose thatyou have to implement a class named Dragonball. This class must have an attribute named ballCount (which starts from 0) and a method iFoundaBall. When iFoundaBall is called, ballCount is increased by one. If the value of ballCount is equal to seven, then the message “You can ask your wish.” is printed, and ballCount is reset to 0. How would you implement this class?
  • 23.
    Question #17 •What arethe 3 scope levels available in PHP and how would you define them?
  • 24.
    Question #18 •What aregetters and setters and why are they important?
  • 25.
    Question #19 •What doesMVC stand for and what does each component do?
  • 26.
    Question #20 •How doesone prevent the following Warning ‘Warning: Cannot modify header information – headers already sent’ and why does it occur in the first place?
  • 27.
    Question #21 •What areSQL Injections, how do you prevent them and what are the best practices?
  • 28.
    Question #22 •What doesthe following code output? $i = 016; echo $i / 2;
  • 29.
    Question #23 •Why wouldyou use === instead of ==?
  • 30.
    Question #24 •What arePSRs? Choose 1 and briefly describe it.
  • 31.
    Question #25 •What PSRStandards do you follow? Why would you follow a PSR standard?
  • 32.
    Question #26 •Do youuse Composer? If yes, what benefits have you found in it?
  • 33.
    More to thinkabout…
  • 34.
    Extra PHP InterviewPractice Questions •What’s the difference between using mysql_ functions and PDO? •Describe how inheritance works with PHP. •Do you know what the PHP-FIG is? Describe it, describe the PSRs you know. •What classes would you create to build a basic Twitter-style status system with OOP? •What frameworks are you experienced in? •What frameworks do you prefer? Why? •Thoughts / experience with unit testing?
  • 35.
    Exercise •Build the Twitterstyle status system mentioned above using PHP (it doesn’t have to run or be error-free). This should be MVP and take less than 30 minutes.
  • 36.
    What Else toBrush Up On Our PHP interview questions here aren’t all-encompassing. Here are some additional concepts that our mentors think may be helpful for you brush up: • Using htmlspecialchars namespaces and short hand array styles [] • How to optimize code & how to pass user supplied data to SQL to avoid injection.
  • 37.
    Good Luck toYour Interview!! For answers and more tutorials: https://www.codementor.io/php/tutorial/php-interview- questions-sample-answers