3K

Php Developer interview questions shared by candidates

Top Interview Questions

Sort: Relevance|Popular|Date
PHP Developer was asked...11 September 2016

Q1. Draw star pattern like. n=1. * n=2. ** * n=3. *** ** * n=4 **** *** ** * n=5. ***** **** *** ** *

#include int main() { int n=10,i,j,s,sum=1,l,k; for(k=1;k=1;i--){ l=sum-i; for(s=1;s&lt;=l;s++){ printf(" "); } for(j=1;j&lt;=i;j++){ printf("*"); } l=l+1; sum=l; printf("\n"); } return 0; } Less

import java.util.Scanner; class New { public static void main(String ... args) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(); int p=n-2; for(int i=1;i&lt;=n;i++) { for(int j=1;j&lt;=(p*(p+1))/2;j++) System.out.print(" "); p--; for(int k=1;k&lt;=n-i+1;k++) System.out.print("*"); System.out.println(""); } } } Less

int main() { int i,j,s,n; scanf("%d",&amp;n); for(i=1;i&lt;=n;i++) { for(s=1;s&lt;=n-i;s++) { printf(" "); } for(j=1;j&lt;=(n+1)-i;j++) { printf("*"); } printf("\n"); } } Less

Given an array of numbers [1,3,3,5,9,4,1,10,9,7,2,7], Write a php function that will print numbers that are not duplicated in array. [5,4,10,2]

The simplest solution for me is to loop through array, unset the current value then check if it is in the array which mean its duplicate and we add it to duplicated values array, if not ,its unique and added to another array for unique numbers .. in every iteration we check the number in the main array and in the duplicated array .. finally we print the unique array. Less

\$firstarray = [1,3,3,5,9,4,1,10,9,7,2,7]; \$secondarray = []; foreach (\$firstarray as \$i) { if (array_key_exists(\$i, \$secondarray)) { \$secondarray[\$i] += 1; } else { \$secondarray[\$i] = 1; } } \$result = []; foreach (\$secondarray as \$i=&gt;\$j) { if (\$j==1) { array_push(\$result, \$i); } } echo var_dump(\$firstarray); echo "<br>"; echo var_dump(\$result); Less

\$firstarray = [1,3,3,5,9,4,1,10,9,7,2,7]; \$secondarray = []; foreach (array_count_values(\$firstarray) as \$i=&gt;\$j) { if (\$j==1) { array_push(\$secondarray, \$i); } } echo var_dump(array_count_values(\$firstarray)); echo "<br>"; echo var_dump(\$secondarray); Less

First round is pattern based question like.. n=1 n=2 n=3 * * * *** *** *** * * * * ***** ***** * * * *******

d if(n==1): l=n;m=n+1 for k in range(n+1): for b in range(l): print(end=" ") l=l-1 if(m&gt;=2): for b in range(3): print("*",end=" ") m=m-1 else: for b in range(3): print("*"*3,end=" ") print(end="\n") elif(n==2): l=n;m=1 for k in range(n+1): if(m&lt;3): for b in range(l): print(end=" ") for b in range(2): print("*",end=" ") m=m+1 else: for b in range(l-2): print(end=" ") for b in range(2): print("*"*5,end=" ") print(end="\n") elif(n==3): l=1;m=1 for k in range(n+1): if(m&lt;4): for b in range(l): print("*",end=" ") m=m+1 else: for b in range(l): print("*"*7) print(end="\n") (Code in Python) Less

def show1(n): m=4-n for _ in range(0,n): print(end=" "*n) print("*"*m,end="\n") for _ in range(m): print("*"*(n*2+1),end=" ") Less

n=int(input()) if n==1: for i in range(n+1): print(" " *(n-i)+"*"*(3*n+6*i)) elif(n==2): for i in range(3): for j in range(13): if(i in {0,1} and j in {3,5}): print("*",end="") elif(i==2 and j in {1,2,3,4,6,7,8,9,10,11,12}): print("*",end="") else: print(" ",end="") print() elif(n==3): for i in range(4): for j in range(6): if(i in {0,1,2} and j==0): print("*",end="") elif(i==3 and j in {0,1,2,3,4,5}): print("*",end="") else: print(" ",end="") print() else: print("",end="\n") Less

whats the angle between the minute pointer and hour pointer at 3:15

at 3:15 hour arrow will indicate to 16minutes. So diff is 1 minute = 360/60 = 6 deg Less

U r right, it's 7.5 =) I was wrong and sleepy

Angle

draw a reversed T pattern which would generate on dynamic series by giving odd input * * * * * @ @ @ @ Second Question is : * * * * * *

Reverse T for odd number. It's dynamic \$x=5; for(\$i=0;\$i'; }

Okay its not getting written here!!

Reverse T for odd number in php. It's dynamic '; } ?&gt;

Get the last thee max salaried person from table via sql.

Just call select query with order by salary with 3 rows limit.

select top 3 salary from employee order by salary desc

"select sal from employ order by sal dec limit 3;"

I was having 8 Yrs of experience but they asked me how to access array elements

They asked very low standard questions

Sorry that you found the question subpar. We have had a candidate once and I reviewed some of their code on screen share. I remember that the candidate had some confusion and said that Arrays is the same Hash Maps which shows lack of understanding of data structures. We are find highly skilled PHP developers who lack understanding of data structures. Unfortunately the nature of business requires our senior developers to have a good command on the basics of programming apart from knowing a language or a framework. I hope that this would explain why our interviewers might ask very basic questions to highly experiences candidates. Less

*Re-commenting because of grammatical errors in the last comment* Sorry that you found the question sub-par. We have had a candidate once who I interviewed. We reviewed some of their code on screen share and I remember that the candidate had some confusion and he believed that Arrays are the same Hash Maps which shows lack of understanding of data structures. We are finding highly skilled PHP developers who lack understanding of data structures and algorithms. Unfortunately (or fortunately), the nature of business requires all of our senior developers to have a good command on the basics of programming apart from knowing a language or a framework. I hope that this would explain why our interviewers might ask very basic questions to highly experiences candidates. Less

12: one ring bells at 20 sec, second will 40 sec and third will 60.at what time these three will ring together?

USE LCM of these 20,40,60.

In 2nd minute

60 mins

Tell me about yourself. What technologies you learnd?

I talked about the university graduated, about the projects carried out and I listed the programming languages ​​learned. Less

I wouldn't stick it out long if your good, the tech stack is rubbish, the framework is just an out of date version of symfony. They might be tedious and pedantic about what they do, it doesn't mean they are any good or moving with the times. Less