Appinventiv Php Developer Interview Questions

Appinventiv Php Developer Interview Questions
Download Appinventiv Php Developer Interview Questions PDF

Appinventiv Php Developer Interview Questions

Overriding and Overloading both are oops concepts.

In Overriding, a method of the parent class is defined in the child or derived class with the same name and parameters. Overriding comes in inheritance.

An example of Overriding in PHP.

<?php

class A {
   function showName() {
      return "Ajay";
   }
}

class B extends A {
   function showName() {
      return "Anil";
   }
}

$foo = new A;
$bar = new B;
echo($foo->myFoo()); //"Ajay"
echo($bar->myFoo()); //"Anil"
?>

In Overloading, there are multiple methods with the same name with different signatures or parameters. Overloading is done within the same class. Overloading is also called early binding or compile time polymorphism or static binding.

An example of Overloading in PHP

<?php 
class A{

function sum($a,$b){
	return $a+$b;

}

function sum($a,$b,$c){
	return $a+$b+$c;

}

}

$obj= new A;
$obj->sum(1,3); // 4
$obj->sum(1,3,5); // 9
?>

You can use library function array_unique() for removing duplicated values for an array. Here is syntax to use it.

<?php
	$a=array("a"=>"home","b"=>"town","c"=>"town","php");
	print_r(array_unique($a));
?>


Some differences are:

GETPOST
It claims request parameter in URL StringIt claims request parameter in the request body
It is able to send a minute amount of dataIt is able to send a great amount of data
It can be cached and bookmarked.It is not able to cache and bookmarked
It is efficient for the view purposeIt is efficient for the update-purpose

Cross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications. XSS enables attackers to inject client-side script into web pages viewed by other users. A cross-site scripting vulnerability may be used by attackers to bypass access controls such as the same-origin policy.

crypt(), Mcrypt(), hash() are used for encryption in PHP

In PHP @ is used to suppress error messages.When we add @ before any statement in php then if any runtime error will occur on that line, then the error handled by PHP