PHP Interview Questions And Answers
PHP is a server-side scripting language, its use to create dynamic web pages, PHP syntax like C & Perl.
Final Class: The final class means that class can not be extended, it's introduced in PHP5.
Final Method: final method can not be overridden
Unlink: The unlink function is dedicated for file system handling. Its use to delete the file given as entry.
Unset: The unset function is dedicated to variable management. it will make variable undefined
(int),(integer): cast to integer
(bool),(boolean): cast to boolean
(float),(double),(real): cast to float
(string): cast to string
(array): cast to array
(object): cast to abject
Answer: func_num_atgs()
select salary from employee order by salary desc limit 1,(n-1)
select u1.name,u2.email from users as u1 inner join (select email from users group by email Having count(id)>1) as u2 on u1.email=u2.email
Traits are a mechanism that allows you to create reusable code in PHP where multiple inheritances is not supported. To create traits we use keyword traits
trait users{
function getUserType(){}
function getUserRes(){}
function getUserDelete(){}
}
class Employee extends Base{
use users;
}
*****
****
***
**
*
<?php
for($i=0; $i<=5; $i++){
for($j=5-$i; $j>=1; $j--){
echo "* ";
}
echo "<br>";
}
?>
*
**
***
****
*****
for($i=0; $i<=5; $i++){
for($j=1; $j<=$i; $j++){
echo "* ";
}
echo "<br>";
}
<?php
$fact=1;
$num=5;
for($i=1; $i<=$num; $i++){
$fact=$fact*$i;
}
echo $fact;
?>
<?php
$check=0;
$num=10;
for($i=2; $i<=($num/2); $i++){
if($num%$i==0){
$check++;
if($check==1){
break;
}
}
}
if($check==0): "Prime";
?>
<?php
$rev=0;
$num=12;
while($num>1){
$re=$num%10;
$rev=(($rev*10)+$re);
$num=$num/10;
}
echo $rev;
?>
<?php
$a=$a+$b;
$b=$a-$b;
$a=$a-$b;
?>
<?php
$a=0;
$b=1;
$end=5;
for($i=2;$i<$end; $i++){
$res=$a+$b;
$a=$b;
$b=$res;
}
?>
strstr(): The string function strstr (string all string, string occ ) returns part of all string from the first occurrence of occ to the end of all.
stristr(): This function is case-sensitive, stristr() is identical to strstr() except that it is case insensitive.
$dt1=date('Y-m-d');
$dt2=date('Y-m-d');
$days=((strtotime($dt2-$dt1)-strtotime($dt1))/(60*60*24));
RewriteEngine On
RewriteCond %{HTTPS}% on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS}% off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
© 2025 Easy To Learning. All Rights Reserved | Design by Easy To Learning