PHP Flashcards

1
Q

Who is designed by PHP ?

A

Rasmus Lerdorf

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

PHP initial release date ?

A

1995

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does PHP stand for?

A

Hypertext Preprocessor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

PHP files have a default file extension of

A

.php

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is/are PHP code editors ?

A

Adobe Dreamweaver
Notepad
Notepad++

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following correct PHP syntax?

A

<?php…?>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is WAMP server ?

A

Windows Apache MySQL PHP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In PHP, instructions are terminated by using what?

A

;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a correct way to add a comment in PHP?

A

//

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you write “Hello World” in PHP

A

echo “Hello World”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What type specifier is invalid in print f() functions ?

A

% a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

PHP Variable start with which symbol?

A

$

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The PHP syntax is most similar to:

A

Perl and C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the correct way to include the file “header.inc” ?

A

<?php include “header.inc”; ?>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In PHP what is the difference between include() and require() ?

A

They are different how they handle failure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

To process image what library needed in PHP?

A

GD Library

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

In PHP, what function is used to insert content of one php file into another php file before server executes ?

A

include()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What function is used to redirect a page ?

A

header()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

PHP variables are_____ ?

A

Multitype variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How can we check the value of a given variable is a number?

A

is_numeric()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What variable assignment is ‘by value’ assignment in PHP ?

A

$value1= $value?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How can we check the value of a given variable is alphanumeric?

A

ctype_alnum()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How do I check if a given variable is empty?

A

empty()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Identify the variable scope that is not supported by PHP ?

A

Hidden variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What is the correct way to create a function in PHP?

A

function myFunction()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is the correct way to open the file “footer.txt” as readable?

A

fopen(“footer.txt”,”r”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Which version of PHP introduced Try/catch Exception ?

A

PHP 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What PHP function can be used to find files ?

A

glob()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

The left association operator % is used in PHP for ?

A

bitwise or

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

In PHP what is the best all-purpose way of comparing two strings ?

A

Using strcmp()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What will be the value of $var?

$var = 1 / 2;

A

0.5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What function returns the number of characters in a string variable ?

A

strlen($variable)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

How do you get information from a form when method is “post”?

A

$_POST[ ];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

In php which method is used to get browser properties?

A

$_SERVER[‘HTTP_USER_AGENT’];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

In PHP what gives a string containing PHP script file name in which it is called ?

A

$_PHP_SELF

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Which superglobal variable holds information about headers, paths, and script locations?

A

$_SERVER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Which type of variables are floating-point numbers, like 3.14159 or 49.1 ?

A

Doubles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

In PHP which method sends input to a script through(via) a URL ?

A

Get

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

What is the correct way to add 1 to the $count variable?

A

$count++;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Which one of these variables has an illegal name?

A

A) $my_Var
B) $my-Var <=this one
C) $myVar
D) $_myVar

B is the correct answer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

Which are compound data type?

A

Array
and
Objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

Which method acts as a constructor function in a PHP class ?

A

__construct

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

How do you create an array in PHP?

A

$cars = array(“Volvo”, “BMW”, “Toyota”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

How do we access the value of ‘d’ later?

$a = array(
‘a’,
3 => ‘b’,
1 => ‘c’,
‘d’
);

A

$a[4]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

What will be printed?

<?php
$a = array(
null => ‘a’,
true => ‘b’,
false => ‘c’,
0 => ‘d’,
1 => ‘e’,
‘’ => ‘f’
);
echo count($a), “\n”;
?>

A

3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

What will be the output of the following PHP code?

<?php
define(“Hi”,”Hello! How are you ?”);
echo constant(“Hi”);
?>

A

Hello! How are you ?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

Which in-built function will add a value to the end of an array ?

A

array_push()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

Which two predefined variables are used to retrieve information from forms ?

A

$_GET & $_SET

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

How to start session in php?

A

session_start()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

What is used to check that a cookie is set or not ?

A

isset() function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

How do you create a cookie in PHP?

A

setcookie()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

In PHP what is not a session function ?

A

A) session_destroy
B) session_decode
C) session_id
D) session_pw

Correct Answer : Option (D) :
session_pw

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

In PHP the function setcookie( ) is used to ?

A

Store data in cookie variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

What is the purpose of $_SESSION[]?

A

Used to store variables of the current session

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

What is the default execution time set in set_time_limit()?

A

30 secs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

Which statement about the code below is correct?

<?php
class A {}
class B {}
class C extends A, B {}
?>

A

class C can not extend both A and B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

Which of the following is true about php.ini file ?

A

A)
The php.ini file is read each time PHP is initialized.
B)
The PHP configuration file, php.ini, is the final and most immediate way to affect the functionality of PHP.
C)
All of the above
D)
None of the above

Correct Answer : Option (C) :
All of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

Which function returns an array consisting of associative key/value pairs ?

A

array_count_values()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

Which operator is used to check if two values are equal and of same data type?

A

===

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

What is the use of explode() in PHP?

A

Used to split a string by a string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

How do I create PHP arrays in a HTML <form>?

A

<input></input>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

In which variable is the users IP address stored?

A

$REMOTE_ADDR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

Which of the following method can be used to create a MySql database using PHP ?

A

mysql_query()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

Which functions is used to get the height of an image :

A

imagesy()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

What is the function file_get_contents() useful for?

A

read

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

Which of the following is NOT a valid PHP comparison operator?

A

&&&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

How to determine number of rows returned in result set?

A

mysqli_num_rows()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

Which one of the following function is used to send a e-mail using PHP script ?

A

mail()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

Which function gives us the number of affected entries by a query?

A

mysqli_affected_rows()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

What is the default upload file size in php?

A

2 MB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q

Which method can be used to close a MySQL database using PHP ?

A

mysql_close()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

In PHP the error control operator is _______ ?

A

@

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

What is the output ?

<?php
define(“x”,”5”);
$x=x+10;
echo x;
?>

A

5

there’s an issue with the code. The constant “x” is defined with double quotes around its name and value, which is not the correct syntax for defining constants in PHP. It should use single quotes or no quotes at all for both the constant name and value. Here’s the corrected code:

define(“x”, 5);
$x = x + 10;
echo $x;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
66
Q

What is the output.

<?php
$x=array(1,3,2,3,7,8,9,7,3);
$y=array_count_values($x);
echo $y[9];
?>

A

1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
67
Q

What will be printed ?

if (null === false) {
echo ‘true’;
} else {
echo ‘false’;

}

A

false

The triple equal sign comparison operator not only checks if the variables are equal in value, but it also confirms that they are of the same type before it returns true or false .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
68
Q

What is the difference between echo and print?

A

Echo can take multiple parameters where as print cannot

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
69
Q

What is the perfect output ?

<?php
$RESULT = 11 + 011 + 0x11;
echo “$RESULT”;
?>

A

37

$RESULT is a variable where the result of a calculation will be stored.

11 is a decimal number (base 10) and is equal to 11.

011 is an octal number (base 8) because it starts with a leading zero. In octal, 011 is equal to 9 in decimal.

0x11 is a hexadecimal number (base 16) because it starts with "0x." In hexadecimal, 0x11 is equal to 17 in decimal.

Now, let’s calculate the result:

11 (decimal) + 9 (octal) + 17 (hexadecimal) = 37 (decimal)

So, the variable $RESULT holds the value 37.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
70
Q

What is the correct abstract method?

A

abstract public function write();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
71
Q

What array represents an array with a numeric index?

A

Numeric Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
72
Q

In mail($param2, $param2, $param3, $param4), the $param2 contains:

A

The subject

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
72
Q

Which of following function return 1 when output is successful?

A

print ( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
73
Q

Which function is used to strip whitespace (or other characters) from the beginning and end of a string?

A

trim

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
74
Q

Which of the following is not true?

A

PHP applications can not be compiled

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
74
Q

If a boolean variable $ alive= 5;

A

$ alive is true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
74
Q

Which PHP functions accepts any number of parameters?

A

func_get_args()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
75
Q

Which of following is not a Superglobals in PHP?

A

$_PUT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
76
Q

What will be the output of the following PHP code?

<?php
$a = 5;
$b = 5;
echo ($a === $b);
?>
A

1

It assigns the value 5 to a variable named "$a."

It assigns the value 5 to another variable named "$b."

It then checks if the value of "$a" is exactly the same as the value of "$b" using "===".

Finally, it prints (echos) the result of this comparison.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
77
Q

Which of the conditional statements is/are supported by PHP?

i) if statements
ii) if-else statements
iii) if-elseif statements
iv) switch statements

A

i), ii), iii) and iv)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
78
Q

Which of the looping statements is/are supported by PHP?

i) for loop
ii) while loop
iii) do-while loop
iv) foreach loop

A

A) i) and ii)
B) i), ii) and iii)
C) i), ii), iii) and iv)
D) None of the above

Correct Answer : Option (C) : i), ii), iii) and iv)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
79
Q

What will be the value of $a and $b after the function call in the following PHP code?

<?php
function doSomething( &$arg ) {
    $return = $arg;
    $arg += 1;
    return $return;	
}
$a = 3;
$b = doSomething( $a );
?>
A

a is 4 and b is 3

The value of $a becomes 4 because it was modified within the doSomething function.
The value of $b becomes 3 because it received the original value of $a before the modification due to the return $return; statement.

So, at the end of this code, $a holds 4, and $b holds 3.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
79
Q

If $a = 12 what will be returned when ($a == 12) ?

A

5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
80
Q

Type Hinting was introduced in which version of PHP?

A

PHP 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
80
Q

What will be the output of the following PHP code?

<?php
function a()
{
function b()
{
echo ‘I am b’;
}
echo ‘I am a’;
}
a();
a();
?>

A

I am a

when run thru a complier: ERROR!
Parse error: syntax error, unexpected identifier “am”, expecting “,” or “;” in /tmp/1HPOaj7nVx.php on line 8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
81
Q

A function in PHP which starts with __ (double underscore) is known as ___

A

Magic Function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
82
Q

PHP’s numerically indexed array begin with position ___________

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
83
Q

Which of the following are correct ways of creating an array?

i) state[0] = “nellore”;
ii) $state[] = array(“nellore”);
iii) $state[0] = “nellore”;
iv) $state = array(“nellore”);

A

iii) and iv)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
84
Q

Which PHP function will return true if a variable is an array or false if it is not an array?

A

is_array()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
85
Q

Which in-built function will add a value to the end of an array?

A

array_push()

86
Q

What function is used to get the value of the previous element in an array?

A

prev()

87
Q

Which function returns an array consisting of associative key/value pairs?

A

array_count_values()

88
Q

Which function should we use to sort the array in natural order?

A

natcasesort()

89
Q

The practice of separating the user from the true inner workings of an application through well-known interfaces is known as _________

A

Encapsulation

90
Q

Which of the following term originates from the Greek language that means “having multiple forms,” defines OOP’s ability to redefine, a class’s characteristics?

A

Polymorphism

91
Q

The practice of creating objects based on predefined classes is often referred to as ______

A

object instantiation

92
Q

What can be used to instantiate an object in PHP assuming class name to be Foo

A

$obj = new foo ();

93
Q

What is the right way to define a constant?

A

const

Example:
const PI = ‘3.1415’;

94
Q

What is the right way to invoke a method?

A

$object->methodName();

95
Q

Which of the following is/are the right way to declare a method?

i) function functionName() { function body }
ii) scope function functionName() { function body }
iii) method methodName() { method body }
iv) scope method methodName() { method body }

A

i) and ii)

96
Q

Which keyword allows class members (methods and properties) to be used without needing to instantiate a new instance of the class?

A

static

97
Q

Which method scope prevents a method from being overridden by a subclass?

A

Final

98
Q

PHP recognizes constructors by the name _________

A

function __construct()

99
Q

Which one of the following keyword is used to inherit our subclass into a superclass?

A

extends

100
Q

Which one of the following is the right way to clone an object?

A

destinationObject = clone targetObject;

101
Q

The class from which the child class inherits is called _______

A

Parent class or Base class

102
Q

Which method is used to tweak an object’s cloning behavior?

A

__clone()

103
Q

Which magic method is used to implement overloading in PHP?

A

__call

104
Q

What is the description of Error level E_ERROR?

A

Fatal run-time error

105
Q

How many error levels are available in PHP?

A

16

106
Q

Say you want to report error concerned about fatal run-time, fatal compile-time error and core error which statement would you use?

A

error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR

107
Q

Which of the following statements causes PHP to disregard repeated error messages that occur within the same file and on the same line?

A

ignore_repeated_errors

108
Q

Which function initializes the constants necessary for using the openlog(), clodelog(), and syslog() functions?

A

define_syslog_variable()

109
Q

Which function is responsible for sending a custom message to the system log?

A

syslog()

110
Q

Which version added the method getPrevious()?

A

PHP 5.3

111
Q

Which one of the following is the right description for the method getMessage()?

A

Returns the message if it is passed to the constructor

112
Q

What does SPL stand for?

A

Standard PHP Library

113
Q

Which of the following is/are an exception?

i) BadFunctionCallException
ii) BadMethodCallException
iii) LogicException
iv) DomainException

A

all of them

114
Q

What filter is used to filter several variables with the same or different filters?

A

filter_var_array()

115
Q

What does not describe a validating filter?

A

Are used to allow or disallow specific characters in a string

116
Q

[:alpha:] can also be specified as ________

A

[A-za-z]

117
Q

POSIX implementation was deprecated in which version of PHP?

A

PHP 5.3

118
Q

POSIX stands for _______

A

Portable Operating System Interface for Unix

119
Q

What will be the output of the following PHP code?

<?php
$text = "this is\tsome text that\nwe might like to parse.";
print_r(split("[\n\t]",$text));
?>
A

[0] => this is [1] => some text that [2] => we might like to parse.

120
Q

What will be the output of the following PHP code?

<?php
function convertSpace($string)
{
    return str_replace("_", " ", $string);
}
$string = "Peter_is_a_great_guy!";
echo filter_var($string, FILTER_CALLBACK, array("options"=>"convertSpace"));
?>
A

Peter is a great guy!

121
Q

What will be the output of the following PHP code?

<?php
$value = 'car';
$result = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
?>
A

NULL

122
Q

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");
?>
A

Integer is not valid

123
Q

What will be the output of the following PHP code?

<?php
$num = "123";
if (!filter_var($num, FILTER_VALIDATE_INT))
    echo("Integer is not valid");
else
    echo("Integer is valid");
?>
A

Integer is valid

124
Q

Which among the following is/are not a metacharacter?

i) \a
ii) \A
iii) \b
iv) \B

A

Only i)

125
Q

What will be the output of the following PHP code?

<?php
$foods = array("pasta", "steak", "fish", "potatoes");
$food = preg_grep("/^s/", $foods);
print_r($food);
?>
A

Array ( [1] => steak )

126
Q

Which functions will convert a string to all uppercase?

A

strtoupper()

127
Q

What will be the output of the following PHP code?

<?php
echo str_pad("Salad", 5)." is good.";
?>
A

Salad  is good

128
Q

Which function can be used to concatenate array elements to form a single delimited string?

A

implode()

129
Q

Which function finds the last occurrence of a string, returning its numerical position?

A

strrpos()

130
Q

What will be the output of the following PHP code?

<?php
$url = "freetimelearn@example.com";
echo ltrim(strstr($url, "@"),"@");
?>
A

example.com

131
Q

The filesize() function returns the file size in _________

A

bytes

132
Q

Which PHP function is used to determine a file’s last access time?

A

fileatime()

133
Q

Which function is capable of reading a file into a string variable?

A

file_get_contents()

134
Q

What function operates similarly to fgets(), except that it also strips any HTML and PHP tags form the input?

A

fgetss()

135
Q

Which one of the following function outputs the contents of a string variable to the specified resource?

A

fwrite()

136
Q

Which function is useful when you want to output the executed command result?

A

system()

137
Q

Which one of the following function reads a directory into an Array?

A

scandir()

138
Q

The date() function returns ___ representation of the current date and/or time.

A

String

139
Q

Which one of the following format parameter can be used to identify timezone?

A

E

140
Q

Which one of the following function is useful for producing a timestamp based on a given date and time?

A

mktime()

141
Q

Which function displays the web page’s most recent modification date?

A

getlastmod()

142
Q

What will be the output of the following code? (If say date is 08/10/2018.)

<?php
echo "Today is ".date("F d, Y");
?>
A

Today is October 08, 2018

143
Q

Suppose you want to calculate the date 45 days from the present date which one of the following statement will you use?

A

strtotime(“+45 days”)

144
Q

Which two predefined variables are used to retrieve information from forms?

A

$_GET & $_SET

145
Q

When you use the $_GET variable to collect data, the data is visible to _______

A

everyone

146
Q

Which variable is used to collect form data sent with both the GET and POST methods?

A

$_REQUEST

147
Q

Which one of the following should not be used while sending passwords or other sensitive information?

A

GET

148
Q

To validate an email address, which flag is to be passed to the function filter_var()?

A

FILTER_VALIDATE_EMAIL

149
Q

In which authentication method does changing the username or password can be done only by entering the code and making the manual adjustment.

A

Hard-coding a login pair directly into the script

149
Q

Which function is used to verify whether a variable contains a value?

A

isset()

149
Q

Which of the following variables does PHP use to authenticate a user?

i) $_SERVER[‘PHP_AUTH_USER’].
ii) $_SERVER[‘PHP_AUTH_USERS’].
iii) $_SERVER[‘PHP_AUTH_PU’].
iv) $_SERVER[‘PHP_AUTH_PW’].

A

i) $_SERVER[‘PHP_AUTH_USER’]
&
iv) $_SERVER[‘PHP_AUTH_PW’].

150
Q

Which function is used to split a string into a series of substrings, with each string boundary is determined by a specific separator?

A

explode()

151
Q

What is one of the most powerful authentication methods?

A

Data-based authentication

152
Q

Which directive determines whether PHP scripts on the server can accept file uploads?

A

file_uploads

153
Q

Which of the following directive determines the maximum amount of time that a PHP script will spend attempting to parse input before registering a fatal error?

A

max_input_time

154
Q

Since which version of PHP was the directive max_file_limit available.

A

PHP 5.2.12

155
Q

Which function is used to determine whether a file was uploaded?

A

is_uploaded_file()

156
Q

What is the full form of DNS?

A

Domain Name System

157
Q

Which of the following statements is used to add an attachment to the mail?

A

$mimemail->addAttachment(‘attachment.pdf’);

158
Q

Which one of the following is the very first task executed by a session enabled page?

A

Check whether a valid session exists

159
Q

Which directive determines how the session information will be stored?

A

session.save_handler

160
Q

If session.use_cookie is set to 0, this results in use of _______

A

URL rewriting

161
Q

Neglecting to set which of the following cookie will result in the cookie’s domain being set to the host name of the server which generated it.

A

session.cookie_domain

162
Q

Which one of the following function is used to start a session?

A

session_start()

163
Q

Which function is used to erase all session variables stored in the current session?

A

session_unset()

164
Q

Which one of the following statements should you use to set the session username to Chanti?

A

$_SESSION[‘username’] = “Chanti”;

165
Q

Which function effectively deletes all sessions that have expired?

A

SessionHandler::gc

166
Q

Which one of the following statements should be used to disable just the fopen(), and file() functions?

A

disable_functions = fopen, file

167
Q

Which one of the following method is invoked when an undefined method is called by client code?

A

__call()

168
Q

Which method introduced in PHP 5, is invoked just before an object is a garbage collected?

A

__destruct()

169
Q

__clone() is run on the ___ object.

A

copied

169
Q

Which one of the following is the correct way of declaring a namespace?

A

namespace my;

170
Q

Which one of the following statements is true for include_once() and require_once()?

A

Both do not handle the errors in the same way

171
Q

Which one of the following functions will you use to check that the class exists before you work with it?

A

class_exists()

172
Q

Which one of the following will you use to check the class of an object?

A

get_class()

173
Q

If you call a method and it doesn’t exist it’ll cause a problem. To check the method which function will you use?

A

is_callable()

174
Q

Which one of the following function should I use to find the parent class of a class?

A

get_parent_class()

175
Q

Which class accepts a class name or an object reference and returns an array of interface name?

A

class_implements()

176
Q

Object-oriented code tries to minimize dependencies by moving responsibility for handling tasks away from ___ and toward the objects in the system.

A

client code

176
Q

_______ code makes change easier because the impact of altering an implementation will be localized to the component being altered.

A

Orthogonal

177
Q

Which one of the following is known as the key to object-oriented programming?

A

Encapsulation

178
Q

UML stands for?

A

unified modeling language

179
Q

In a class diagram the class is divided into three sections, what is displayed in the first section?

A

Class Name

180
Q

______ are used in class diagrams to describe the way in which specific elements should be used.

A

Constraints

181
Q

+ is the visibility code for?

A

Public

182
Q

What will be the output of the following PHP code?

<?php
$color = red;
echo “$color”;
?>

A

$color

182
Q

Inheritance in class diagrams is depicted by________

A

single-headed empty arrow

183
Q

What will be the output of the following PHP code?

<?php
$color1 = red;
$color2 = green;
echo “$color1”.”$color2”;
?>

A

ERROR!
Fatal error: Uncaught Error: Undefined constant “red” in /tmp/uVn1YGHHJv.php:4
Stack trace:
#0 {main}
thrown in /tmp/uVn1YGHHJv.php on line 4

184
Q

What will be the output of the following PHP code?

<?php
$color1 = “red”;
$color2 = “green”;
echo “$color1” + “$color2”;
?>

A

0

185
Q

<?php
$color1 = “1”;
$color2 = “1”;
echo “$color1” + “$color2”;
?>

A

2

186
Q

What will be the output of the following PHP code?

<?php
$x = 5;
$y = 10;
$z = “$x + $y”;
echo “$z”;
?>

A

10+5

187
Q

What will be the output of the following PHP code?

<?php
$x = 3.3;
$y = 2;
echo $x % $y;
?>

A

1

188
Q

What will be the output of the following PHP code?

<?php
$x = 4;
$y = 3;
$z = 1;
echo “$x = $x + $y + $z”;
?>

A

4 = 4 + 3 + 1

189
Q

What will be the output of the following PHP code?

<?php
$x = 4;
$y = -3;
$z = 11;
echo 4 + $y * $z / $x;
?>

A

-4.25

190
Q

What will be the output of the following PHP code?

<?php
$on$e = 1;
$tw$o = 2;
$thre$e = 3;
$fou$r = 4;
echo “$on$e / $tw$o + $thre$e / $fou$r”;
?>

A

Error

191
Q

What will be the output of the following PHP code?

<?php
$hello = “Hello World”;
$bye = “Bye”;
echo $hello;”$bye”;
?>

A

Hello World

192
Q

What will be the output of the following PHP code?

<?php
$a = “$winner”;
$b = “$looser”;
echo $a, $b;
?>

A

$looser

193
Q

What will be the output of the following PHP code?

<?php
$x = 5;
$y = 10;
function fun()
{
$GLOBALS[‘y’] = $GLOBALS[‘x’] + $GLOBALS[‘y’];
}
fun();
echo $y;
?>

A

15

194
Q

<?php
function fun()
{
static $x = 0;
echo $x;
$x++;
}
fun();
fun();
fun();
?>

A

012

194
Q

What will be the output of the following PHP code?

<?php
$x = 0;
function fun()
{
echo $GLOBALS[‘x’];
$x++;
}
fun();
fun();
fun();
?>

A

000

195
Q

What will be the output of the following PHP code?

<?php
$a = 10;
echo ++$a;
echo $a++;
echo $a;
echo ++$a;
?>

A

11111213

196
Q

What will be the output of the following PHP code?

<?php
$x = “test”;
$y = “this”;
$z = “also”;
$x .= $y .= $z ;
echo $x;
echo $y;
?>

A

testthisalsothisalso

197
Q

What will be the output of the following PHP code?

<?php
$y = 2;
if (**$y == 4)
{
echo $y;
}
?>

A

error at line2

197
Q

What will be the output of the following PHP code?

<?php
$y = 2;
if (–$y == 2 || $y xor –$y)
{
echo $y;
}
?>

A

0

198
Q

What will be the output of the following PHP code?

<?php
$y = 2;
$w = 4;
$y *= $w /= $y;
echo $y, $w;
?>

A

42

199
Q

What is Joomla in PHP?

A

An open-source CMS (Content Management System)

200
Q

Can I generate DLL files from PHP scripts like in Perl?

A

No, you cannot generate DLL (Dynamic Link Library) files directly from PHP scripts like you can in Perl.

201
Q

In mysql_fetch_array() if two or more columns of the result have the same field names, what action is taken?

A

the last column will take precedence

202
Q

In which variable is the users IP address stored?

A

$REMOTE_ADDR

203
Q

What is the difference between GET and POST method?

A

GET displays the form values entered in the URL of the address bar where as POST does not.

204
Q

What is x+ mode in fopen() used for?

A

Read/Write. Creates a new file. Returns FALSE and an error if file already exists

205
Q

Can I run several versions of PHP at the same time?

A

Yes

206
Q

Can I have new lines in $subject tag of php’s mail function?

A

No

207
Q

What is the use of mysql_pconnect()?

A

-Used to create a persistant connection to mysql server.
- Used to return an identifier of an existing open connection before opening new connection.

208
Q

Which function is used to strip whitespace (or other characters) from the beginning and end of a string?

A

trim

209
Q

Can we use include (”test.php”) two times in a PHP page “test1.PHP”?

A

Yes

210
Q

What is the strpos() function used for?

A

Search for character within a string

211
Q

How can I run COM object from remote server ?

A

like we run local objects
pass the IP of the remote machine as second parameter to the COM constructor.

212
Q

PHP supports explicit type definition in variable declaration.

A

False

213
Q

How do I find out the number of parameters passed into function?

A

By using func_num_args()

214
Q

What is PHP heredoc used for?

A

allows creating multiple lines of string without using quotations

215
Q

Parent constructors are not called __________ if the child class defines a constructor

A

implicitly

216
Q

____________ function in PHP returns a list of response headers sent (or ready to send)

A

headers_list()

217
Q

What happens if no file path is given in include() function?

A

Include_path is made use of

218
Q

A PHP function cannot be overloaded or redefined

A

True

219
Q

How is the setrawcookie function different from the setcookie function?

A

setrawcookie sets the cookie without URL encoding the value, while setcookie URL encodes the value by defualt

220
Q

what is the parameter passed to the fgets() function in php to read a single line from a file?

A

the file pointer to read from

221
Q

what is the output of the following code?

$i =1;
do{echo$i; $i++;}
while($i<=5);

A

12345

222
Q

which keyword is used to declare a class as protected in php?

A

protected

223
Q

which keyword is used to pass an object as a reference in php

A

&

224
Q

what happens when a form is submitted to a php script that contains two elements with the same name?

A

VAlue of the second element overwrites the first in specific super global array