Here are some problems that were given as part of coding test, to freshers(those with no experience/new graduates) and those with experience, by a few companies for the job of PHP Developer:
Problem 1: Generate a Fibonacci sequence as shown below 1,2,3,5,8,13,21,34,….The generated sequence should contain the first 100 terms.
Problem 2: Given a sequence like this, 1,5,6,8,9,4,11,12,11,44,56,78,100 – Write a php class that will take in the above sequence, search and find any term in that sequence including its frequency in that sequence.
Problem 3: We have a sentence like this – “Hello World A, B is from mars, C is from Jupiter and D is from neptune”. Take this sentence and concatenate into a single string as show below:
Problem 4: Given a sentence like this ” Hello World, A is from Mars”. Write php code to change that sentence to this “HELLO WORLD, A IS FROM MARS” and to this “hello world, a is for mars” and to this “hhhhh wwwww, a ii, ffff mmmm”.
For those with one or more years of experience in PHP:
Problem 1: Create a HTML form using PHP. There should be three fields on the form – patient name, appointment date and doctors name. Assume that there are 5 patients and one doc who works from 9 to 5 monday to friday. Write code that will schedule a patient to the doc using vacant slot in the appointment time. If a patient books for appointment after 5pm that appointment should be posted to the next day. No two patients can have the appointment at the same time and it will be first come first serve basis. Each appointment should last only for 30 minutes. You can make any further assumptions you want but you should be able to justify them.
Problem 2: Suppose you create a simple car dealer’s website. On the site there should be a drop down with car manufacturers. When a manufacturer is selected another drop down should show up with all the vehicles manufactured by them. When a vehicle is selected, its picture and description should show up (pictures will be given). Use Jquery wherever possible.
Problem 3: Write PHP code to demonstrate method overloading and method overriding using php.
Problem 4: Write PHP code to demonstrate inheritance in php.
Problem 5: Using ‘Animal’ as an abstract class, demonstrate its use in a class called ‘Cow’.
Some more projects for fun:
Problem 1: Create a simple webservice using PHP. The webservice should give the capital of any country. For example: If I sent the string ‘United States’ to the web service it should reply back as ‘Washington DC’, if i sent ‘Japan’ it should return ‘Tokyo’ and so on.