- which MIME type needs to be used to send an attachment in mail ?
- What is the output of the following code ?
class Foo {private $foo;
protected $bar;
public $test;
public function __construct()
{
$this->foo = 1;
$this->bar = 2;
$this ->test = 3;
}
}
print_r( (array) new Foo );
- Array([Foofoo]=>1 [*bar]=>2[test]=>3)
- By default, every database connection opened by a script is either
explicitly closed by the user during run time of released__________
at the end of the script.
- Which magic method is used to implement overloading in PHP ?
- What will be the output of following code ?
<?php $i = 016;echo $i /2;
?>
- Which of the following file modes is used to write into a file
at the end of the existing content, and create the file if the file does
not exist ?
- Which of the following statements is incorrect with respect to inheritance in PHP?
- A Class can extend more than one class.
- You can extend the exception class, but you cannot override any of the preceding methods they are declared as :
- What is the correct syntax of mail() function in php ?
- mail($to,$subject,$message,$headers)
- What is the fastest way to insert an item $item into the specified position $position of the array $array ?
- array_merge() and array_slice()
- Which of the following MySQL fetch
constants imply: if the columns are returned into the array having both a
numerical index and the field name as the array index ?
- Which function is used to get the number of arguments passed to the function ?
- What is the output of the following code ?
<?phpfunction abc(){
return_FUNCTION_;
}
function xyz()
{
return abc();
}
echo xyz();
?>
- � Which Function can be used to determine if a file exist? (choose all that apply)
file_exists(),
is_file_exists()
- What will be the output of following code
<?phpclass A {
public static function foo() {
static::who();
}
public static function who(){
echo __CLASS__.”\n”;
}
}
class B extends A {
public static function test(){
A::foo();
parent::foo();
self::foo();
}
public static function who() {
echo __CLASS__. “\n”;
}
}
Class C extends B {
public static function who(){
echo __CLASS__.”\n”;
}
}
C::test();
?>
- Which of the following will print out the PHP call stack ?
var_dump($e->getTraceAsString())
- What is the correct way to send an SMTP(Simple Mail Transfer Protocol) email using PHP?
- sendmail($EmailAddress,”Subject”,”$MessageBody);
- The PDO_MYSQL Data Source Name(DSN) is composed of the following elements ?
unix_socket
charset
- Which is true about the curl_setopt() API ?
- It sets one option for cURL transfer
- What will be the output of the following PHP code ?
<?php$var=300;
$int options = array(“options”=>array(“min_range”=>0,”max_range”=>256));
if(!filter_var($var,FILTER_VALIDATE_INT, $int_options))
echo(“Integer is not valid”);
else
echo(“Integer is valid”);
?>
- Which function is used to read a file removing the HTML and PHP tags in it ?
- What will the output of following code :-
<?phpclass BaseClass {
public function test() {
echo “BaseClass::test() called\n”;
}
final public function moreTesting() {
echo “BaseClass::moreTesting() called \n”;
}
}
class ChildClass extends BaseClass {
public function moretesting(){
echo “ChildClass::moreTesting() called\n”;
}
}
$obj = new ChildClass;
$obj->moreTesting();
?>
- Results in Fatal error : Cannot override final method
BaseClass::moreTesting();
- What will happen if a fatal error was thrown in your PHP program ?
- The PHP program will stop executing at the point where the error
occured.
- Which of the following code can be used to send email to multiple recipients ?
- $recipients = array(‘recipient1@domain.com’,’receipient2@domain.com);
mail($recipients,$subject,$messege,$headers);
- Which of the following functions belong to Exception class ? (Choose all that apply)
getTraceAsString();
- Which of the following are valid MySQLi Configuration options ? (Choose all that apply ?
mysqli.default_port
mysqli.default_socket
- Which is the best approach to parse HTML and extract structured information from it ?
- Use an XML parser (as simpleXML) and XPath queries if available.
- What is the output of the following code ?
<?phpfunction y($v) {
echo $v;
}
$w = “y”;
$w (“z”);
$w = “x”;
?>
- Xdebug is a PHP____________, the information which Xdebug provides
is about stack and functions with full parameter for user defined
functions, memory allocation and support for infinite recursions.
- See the example class code below
class ExampleClass{
public $val = 5 ;
function &getValNum()
{
return $this->val;
}
}
which of the following one can be used for Return by reference ?
- $obj = new ExampleClass();
$myVal = $obj->getValNum();
- What is the output of following code ?
function myFun($a) {if(!$a){
throw new Exception(‘Value init.’);
}
return 3/$a;
}
try {
echo myfun(3) .”\n”;
}catch (Exception $e){
echo ‘Caught exception: ‘, $e->getMessage(), “\n”;
} finally {
echo “first\n”;
}
try{
echo myFun(1).”\n”;
} catch (Exception $e) {
echo ‘Caught exeption:’, $e->getMessage(),”\n”;
} finally {
echo “second\n”;
}
echo “Hello PHP Example\n”;
- 1 first 3 second Hello PHP Example
- What is true about ini_set(‘memory_limit’,’-1’) ?
- what is the correct way to read-in multiple values from an array ?
- list($x,$y,$z) = array(7,8,9);
- What is the best practice for running MySQL queries in PHP? Consider the risk of SQL injection ?
- Use PDO prepared statements and parameterized queries
- Which of the following is the right MIME to use as a Contant Type for JSON data ?
- Which of the following is the correct way to convert a variable from a string to an integer ?
- $number_variable = (int)$string_variable;
- There are a number of mysqlnd plugins already available. These include
- PECL/mysqlnd_pscache – Prepared Statement Handle Cache plugin
PECL/mysqlnd_sip – SQL Injection Protection Plugin
PECL /mysqlnd_uh – User Handler Plugin
PECL/mysqlnd_qc – Query Cache Plugin
- What will be the output of executing the following code ?
- Fata error : Call to private method Foo:: printName() from context
- When designing classes with UML, a class at its core has the following components ? (choose all that apply)
- Which of the following would show an error in php ?
- What would be the output of the following code ?
$str = “0011110000bsts11100”;echo trim($str,’010s’);
- What would be the output of the I and II sample codes:
I)$a = array();
$b = $a;
$b[‘foo’] = 42;
echo $a[‘foo’];
II)
$a = new StdClass();
$b = $a;
$b->foo = 42;
echo $a->foo;
- Which of the following is not a Super Global variable in PHP ?
- Which of the following would produce an error :
$currentDT = new DateTime();
- $currentDT->getTimezone(new DateTimeZone(‘UTC’));
- Which statement is incorrect ?
- unset() forces the PHP garbage collector to immediately.
- which of the following is not related to garbage collection in PHP ?
- which statement is not correct ?
$x = null;
- What would be the output of the following code ?
$parts = parse_url(“https://example.com/test/1234?testing&val&id=1&&=23&row=4”);
parse_str($parts[‘query’],$query);
echo count($query);
- Which of the following is not the correct way to create an empty object in PHP ?
- Which function is used to destroy a variable or object ?
- What will be the output of the following code ?
$arr = array(“THEY”,”WE”,array(“I”,”YOU”),”YOUR”);
echo(count($arr,1));
- Which statement is not correct ?
- PHP_EOL – The correct ‘End of Line’ symbol for this platform.
- Which method is used to tweak an oject’s cloning behavior ?
- How do you access result set meta data ?
<?php
$mysqli = new mysqli(“example.com”, “user”, “password”, “database”);
if ($mysqli->connect_errno) {
echo “Failed to connect to MySQL: (” . $mysqli->connect_errno . “) ” . $mysqli->connect_error;
}
$res = $mysqli->query(“SELECT 1 AS _one, ‘Hello’ AS _two FROM DUAL”);
var_dump($res->fetch_fields());
?>
- Which of the following will decode a JSON variable $json to an object ?
$json = ‘{“abc”:1,”def”:2,”ghi”:3,”jkl”:4,”mno”:5}’;
- both of above ($object = json_decode($json); and $object = json_decode($json,true);)
- Choose the correct option to force redirect from http to https :
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
- What will be the output of executing the following code ?
<?php
class Foo {
private function printName($name) {
print_r($name);
}
}
$a = new Foo();
$a->printName(‘James’);
?>
- Fatal error: Call to private method Foo::printName() from context…
- What will be the output of the below code ?
$tmp = “Dragon%%Ball%%z%”;
$arr = explode(‘%’,trim($tmp));
echo count($arr);
- Which of the following options will fall to remove the element “y” when placed in the blank space in the below sample code
$row = array(0=>”x”,1=>”y”,2=>”z”,3=>”w”)
print_r($row)
- Which of the following is the correct option to get a numerically
indexed array containing all defined timezone identifiers in PHP
- DateTimeZone::listIdentifiers(DateTimeZone::UTC);
- What will be the output of the following code ?
echo(1234==’1234 test’ ? ‘Equal’ : ‘Not equal’);
- After the following query is executed using PHP, which function can
be used to count the number of rows returned ?(choose all that apply)
SELECT * from students
mysqli_numrows()