SlideShare a Scribd company logo
1. What does the following code return?
$arr = array(1,3,5);
$count = count($arr);
if ($count = 0) {
   echo "An array is empty.";
} else {
   echo "An array has $count elements.";
}
     1. An array has 3 elements.
     2. An array consists of 0 elements.
     3. An array is empty.
Answer: 2

2.What is the result of the following code?
$a = 10;
if($a > 5 OR < 15)
 echo "true";
else
 echo "false";
    1. true
    2. false
    3. There is a syntax error will display.
    4. Nothing will be displayed.
Answer: 3

3. Which of the statements is not true of the interfaces?
    1. A class can implement multiple interfaces.
    2. Methods with the same names and arguments can exist in multiple interfaces, this class
       implements.
    3. An abstract class can implement multiple interfaces.
    4. The interface itself can extend multiple interfaces.
Answer: 2

4. If you want to pass the argument of the function by reference, the correct path would be:
     1. function ModifyReport(&$Rptfile){}
     2. function ModifyReport($Rptfile){}
     3. function ModifyReport(ByRef $Rptfile){}
     4. function ModifyReport(&Rptfile){}
Answer: 1

5.Which of the following pairs of operators are not opposite?
   1. +, -
   2. &=, |=
   3. ==, !=
   4. <<, >>
Answer: 2


1|Page                                         Pankaj Kumar Jha (www.globaljournals.org)
6. Which of the following casts are not true?
<?php
$fig = 23;
$varbl = (real) $fig;
$varb2 = (double) $fig;
$varb3 = (decimal) $fig;
$varb4 = (bool) $fig;
?>
    1. real
    2. double
    3. decimal
    4. boolean
Answer: 3

7. Choose false statement about abstract classes in PHP5.
    1. Abstract classes are introduced in PHP5.
    2. An abstract method's definition may contain method body.
    3. Class with at least one abstract method must be declared as abstract.
    4. An abstract class may contain non-abstract methods.
Answer: 2

8. Which of the following functions returns the longest hash value?
    1. sha1()
    2. md5()
    3. crc32()
    4. All these functions return the same hash value.
Answer: 1

9. Which of these characters can be processed by the htmlspecialchars() function?
    1. ' - single quote
    2. '' - double quote
    3. < - less than
    4. > - greater than
    5. & - an ampersand
    6. All
Answer: 6

10. Choose all valid PHP5 data types.
    1. money
    2. varchar
    3. float
    4. char
    5. complex
Answer: 3




2|Page                                      Pankaj Kumar Jha (www.globaljournals.org)
11. How many parameters can be passed to this function?
<?
function f() {
  ...
}
?>
     1. 0 (zero)
     2. 1 (one)
     3. that amount determined by the php configuration.
     4. any number of params.
Answer: 4

12. What gets printed?
<?php
$var = 'false';

if ($var) {
    echo 'true';
} else {
    echo 'false';
}
?>
Answer: true [This is a string literal, which converts to Boolean true ]

13. Which of the following is used to declare a constant
   1. const
   2. constant
   3. define
   4. #pragma
   5. Def

Answer: 3
Here is an example of declaring and using a constant:
define(PI, 3.14);
printf("PI = %.2fn", PI);

14. What will be printed?
<?php
$var = '0';
if ($var) {
    echo 'true';
} else {
    echo 'false';
}
?>
Answer: false


3|Page                                               Pankaj Kumar Jha (www.globaljournals.org)
15. What will be the value of $var?

<?php     $var = 1 / 2; ?>
   1.    0
   2.    0.5
   3.    1

Answer:2

16. How do we access the value of 'd' later?
$a = array( 'a', 3 => 'b', 1 => 'c', 'd' );
    1. $a[0]
    2. $a[1]
    3. $a[2]
    4. $a[3]
    5. $a[4]

Answer: 5

17. Which of the following is NOT a magic predefined constant?
    1. __LINE__
    2. __FILE__
    3. __DATE__
    4. __CLASS__
    5. __METHOD__

Answer: 3

18. What will be printed?
$a = array();
if ($a == null) {
  echo 'true';
} else {
  echo 'false';
}

Answer: true[empty array converts to null ]

19. What will be printed?
if (null === false) {
  echo 'true';
} else {
  echo 'false';
}
Answer: false
=== is true if values are equal and of the same type, false is of the boolean type, but null is of the special null type



4|Page                                                  Pankaj Kumar Jha (www.globaljournals.org)
20. What gets printed?
<?php
$RESULT = 11 + 011 + 0x11;
echo "$RESULT";
?>
    1. 11
    2. 22
    3. 33
    4. 37
    5. 39
Answer: 4 [A decimal plus an octal plus a hex number. 11 + 9 + 17 = 37 ]

21. What will be the value of $var below?
$var = true ? '1' : false ? '2' : '3';
    1. 1
    2. 2
    3. 3

Answer: 2[ternary expressions are evaluated from left to right]

22. What will be printed?
if ('2' == '02') {
  echo 'true';
} else {
  echo 'false';
}

Answer: true [Numerical strings are compared as integers]

23. Which of the following is NOT a valid PHP comparison operator?
    1. !=
    2. >=
    3. <=>
    4. <>
    5. ===
    6.
Answer:3

24. What will be printed?
$var = 'a';
$VAR = 'b';
echo "$var$VAR";
    1. aa
    2. bb
    3. ab

Answer: 3[Variable names are case-sensitive]


5|Page                                             Pankaj Kumar Jha (www.globaljournals.org)
25. What will be printed?

$a = array( null => 'a', true => 'b', false => 'c', 0 => 'd', 1 => 'e', '' => 'f');
echo count($a), "n";
   1. 2
   2. 3
   3. 4
   4. 5
   5. 6

Answer: 2[Keys will be converted like this: null to '' (empty string), true to 1, false to 0 ]

26. What gets printed?

class MyException extends Exception {}
try {
  throw new MyException('Oops!');
} catch (Exception $e) {
  echo "Caught Exceptionn";
} catch (MyException $e) {
  echo "Caught MyExceptionn";
}

Answer: Caught Exception [The first catch will match because MyException is a subclass of Exception, so the
second catch is unreachable ]

27. What will be printed?

$a = array();
if ($a[1]) null;
echo count($a), "n";
     1. 0
     2. 1
     3. 2
     4. this code won't work

Answer: 1[checking value in if() does not create an array element ]

28. What will be printed by the below code?

$a = 1;
{
  $a = 2;
}
echo $a, "n";

Answer: 2 [PHP variables only have a single scope (except in functions) ]


6|Page                                                  Pankaj Kumar Jha (www.globaljournals.org)
29. What gets printed?
<?php
$str = 'abn';
echo $str;
?>
    1. ab(newline)
    2. ab(newline)
    3. abn
    4. ab(newline)
    5. abn
Answer: 3 [ is a special case in single-quoted string literals, which gives a single , n is not interpolated in single-
quoted string literals ]

30. Which statement about the code below is correct?

class A {}
class B {}
class C extends A, B {}

    1.   the code is perfectly fine
    2.   classes can not be empty
    3.   class C can not extend both A and B
    4.   qualifiers 'public' or 'private' are missing in class definitions

Answer: 3 [A class can only inherit one base class ]

31. What gets printed?

<?php
$x=array("aaa","ttt","www","ttt","yyy","tttt");
$y=array_count_values($x);
echo $y[ttt];
?>
a)2
b)3
c)1
d)4

Answer: a
eg:
<?php
$array = array(1, "hello", 1, "world", "hello");
print_r(array_count_values($array));
?>

After execution of above script we will get output:
Array


7|Page                                                 Pankaj Kumar Jha (www.globaljournals.org)
(
    [1] => 2 //1 came two times in array
    [hello] => 2 //Hello came two times in array
    [world] => 1
)

32. What's the best way to copy a file from within a piece of PHP?
    1. Print out a message asking your user to "telnet" in to the server and copy the file for you
    2. Open the input and output files, and use read() and write() to copy the data block by
       block until read() returns a zero
    3. Use the built in copy() function
    4. Use "exec" to run an operating system command such as cp (Unix, Linux) or copy
       (Windows)

Answer: 3

33. In    php Which method is used to getting browser properties?
    1.     $_SERVER['HTTP_USER_AGENT'];
    2.     $_SERVER['PHP_SELF']
    3.     $_SERVER['SERVER_NAME']
    4.     $_SERVER['HTTP_VARIENT']

Answer: 1

34. Assume that your php file 'index.php' in location c:/apache/htdocs/phptutor/index.php. If you
used $_SERVER['PHP_SELF'] function in your page, then what is the return value of this
function ?
    1. phptutor/index.php
    2. /phptutor/index.php
    3. c:/apache/htdocs/phptutor/index.php
    4. index.php

Answer: 2

35. What will be the ouput of below code ?
Assume that today is 2009-5-19:2:45:32 pm
<?php

$today = date("F j, Y, g:i a");

?>

     1.    May   19,09,2:45:32 PM
     2.    May   19, 2009, 2:45 pm
     3.    May   19,2009,14:45:32 pm
     4.    May   19,2009,14:45:32 PM



8|Page                                       Pankaj Kumar Jha (www.globaljournals.org)
Answer: 2

36. What function used to print statement in PHP?
   1. echo();
   2. printf
   3. "
Answer: 1

37. <?php
define("x","5");
$x=x+10;
echo x;
?>
    1. Error
    2. 15
    3. 10
    4. 5

Answer: 4

38. PHP variables are
    1. Multitype variables
    2. Double type variables
    3. Single type variable
    4. Trible type variables

Answer: 1

39. Which of these statements is true?
    1. PHP interfaces to the MySQL database,and you should transfer any data in Oracle or
       Sybase to MySQL if you want to use PHP on the data.
    2. PHP interfaces to a number of relational databases such as MySQL, Oracle and
       Sybase. A wrapper layer is provided so that code written for one database can easily be
       transferred to another if you later switch your database engine.
    3. PHP interfaces to a number of relational databases such as MySQL, Oracle and Sybase
       but the interface differs in each case.
    4. There's little code in PHP to help you interface to databases, but there's no reason why
       you can't write such code if you want to.

Answer: 3

40. Which of the following is used to check if a function has already been defined?
    1. bool function_exists(functionname)
    2. bool f_exists(functionname)
    3. bool func_exist(functioname)

Answer: 1


9|Page                                     Pankaj Kumar Jha (www.globaljournals.org)
41. Assume that your php file 'index.php' in location c:/apache/htdocs/phptutor/index.php. If you
used basename($_SERVER['PHP_SELF']) function in your page, then what is the return value
of this function ?
    1. phptutor
    2. phptutor/index.php
    3. index.php
    4. /index.php

Answer: 3

42. Below program will call the function display_result() ?
<?php
$x="display";
${$x.'_result'} ();
?>
    1. False
    2. True
    3. Parser Error
    4. None of the above

Answer: 2

43. What gets printed?

<?php
$str="3dollars";
$a=20;
$a+=$str;
print($a);
?>
    1. 23dollars
    2. 203dollars
    3. 320dollars
    4. 23

Answer: 4

44. What gets printed?

<?php
function zz(& $x)
{
        $x=$x+5;
}
?>
$x=10;


10 | P a g e                                  Pankaj Kumar Jha (www.globaljournals.org)
zz($x);
echo $x;

   1.   5
   2.   0
   3.   15
   4.   10

Answer: 3

45. What is the following output?

<?php
$x=dir(".");
while($y=$x->read())
{
echo $y."
"
}
$y->close();
?>

   1.   display all folder names
   2.   display a folder content
   3.   display content of the all drives
   4.   Parse error

Answer: 2

46. <?php
$test="3.5seconds";
settype($test,"double");
settype($test,"integer");
settype($test,"string");
print($test);
?>

What is the following output?
  1. 3.5
  2. 3.5seconds
  3. 3
  4. 3second

Answer: 3

47. PHP is
    1. Partially cross-platform


11 | P a g e                                Pankaj Kumar Jha (www.globaljournals.org)
2. Truly cross-platform
     3. None of above

Answer: 2

48. PHP is a _____ . It means you do not have to tell PHP which data type the variable is.PHP
automatically converts the variable to the correct data type, depending on its value.
    1. client side language
    2. local language
    3. global language
    4. loosely typed language

Answer: 4

49. Which of the following function is used to change the root directory in PHP?
    1. choot()
    2. change_root()
    3. cd_root()
    4. cd_r()
Answer: 1

50. The PHP syntax is most similar to:
    1. PERL and C
    2. Java script
    3. VB Script
    4. Visual Basic

Answer: 1

51. What will be the output of below code ?
<?php

$arr = array(5 => 1, 12 => 2);
$arr[] = 56;
$arr["x"] = 42;
echo var_dump($arr);

?>

     1.   42
     2.   array(3) { [12]=> int(2) [13]=> int(56) ["x"]=> int(42) }
     3.   array(4) { [5]=>int(1) [12]=> int(2) [13]=> int(56) ["x"]=> int(42) }
     4.   1,2,56,42

Answer: 3

52. What is the output of the following PHP script?


12 | P a g e                                      Pankaj Kumar Jha (www.globaljournals.org)
<?php
 define('SOMEVAL', 0);

  if (strlen(SOMEVAL) > 0) {
      echo "Hello";
  }
  else {
      echo "Goodbye";
  }
?>
    1. Goodbye
    2. Hello
    3. Syntax Error

Answer:

53. Consider the following PHP code:
<?php
  $myArray = array(
     10, 20, 30, 40
  );
?>

What is the simplest way to return the values 20 and 30 in a new array without
modifying $myArray?

   1.   array_slice($myArray, 1, 2);
   2.   array_splice($myArray, 2, 1);
   3.   array_slice($myArray, 2, 1);
   4.   array_slice($myArray, 10, 20);

Answer:


54. What will this output

   <?php
   $a = false;
   $b = true;
   $c = false;

   if ($a ? $b : $c) {
   echo "false";
   } else {
   echo "true";
   }
   ?>


13 | P a g e                             Pankaj Kumar Jha (www.globaljournals.org)
Answer: true

Explanation: If $a is true, then $b will be evaluated; otherwise (as is the case here) $c will be
evaluated. As $c is false, the conditional evaluates as false, and the script (confusingly) prints
true.

55: What can you use to replace like with hate in I like Regular Expressions?

Answer: preg_replace("/like/", "hate", "I like Regular Expressions")

Explanation: The search is a regular expression and it has slashes around it, the replace isn't,
so it doesn't have any slashes.

56. What library do you need in order to process images?

Answer. GD library

57. What function sends mail:

Answer: imap_mail, mail

58: What is the problem with <?=$expression ?> ?

Answer: It requires short tags and this is not compatible with XML

Explanation: If you have short_open_tag On then this XML <?xml version="1.0" encoding="utf-
8"?> (for example) will be parsed by the PHP engine, causing both a PHP and a XML parsing
error.

59: Put this line php display_errors=false in a .htaccess file when you deploy the application?
Answer: That won't hide any error 'coz it's not the correct code

Explanation: I would have said 'Good idea, increases security', but wait a minute... the correct
syntax is php_flag display_errors Off ...

60. Which of the following regular expressions will match the string go.go.go?
Answer: ........

Explanation: Any character (twice) followed by a period followed by any character (twice)
followed by ...

61: A constructor is a special kind of _______________

Answer: Method

Explanation: It is a function, but since it's in a class we call it a method.


14 | P a g e                                    Pankaj Kumar Jha (www.globaljournals.org)
62: What does break; do?

Answer: Ends execution of the current for, foreach, while, do-while or switch structure

Explanation: Yup. If you were tempted to say 'moves on to the next iteration', that's the continue
statement.

63: Can this PHP code be valid:

$4bears = $bears->getFirst4();

Answer: No

Explanation: A variable name can't start with a number. Don't ask me why not, I don't see any
reason why it shouldn't; it's probably some carry over from C.

64. What will this output:
<?php
$dog = "Dogzilla";
$dragon = &$dog;
$dragon = "Dragonzilla";

echo $dog." ";
echo $dragon;
?>

Answer: Dragonzilla Dragonzilla

Explanation: $dragon is really $dog, it just has a different name.

65: Assuming all the variables a, b, c have already been defined, could this be a variable name:
${$a}[$b][$c] ?

Answer: Yes

Explanation: Yup, it's a multidimensional array.

66: In MySQL, if you want to find out about the structure of a table tblQuiz, what will you use?

Answer: DESCRIBE tblQuiz

67: In which of the following scenarios might you use the function md5?
    1. perform large number multiplication
    2. perform authentication without unnecessarily exposing the access credentials

Answer: 2


15 | P a g e                                  Pankaj Kumar Jha (www.globaljournals.org)
Explanation: md5 returns an unique hash string for the string you pass it; if you have only the
hash it's practically impossible to find the string that produces it.

68: What does this function do:

<?php
function my_func($variable)
{
        return (is_numeric($variable) && $variable % 2 == 0);
}
?>

Answer: tests whether $variable is an even number

Explanation: It returns true if $variable is divisible by 2.

69: How do you find the square root of a number?

Answer: In both PHP and MySQL you have a function called sqrt

70: Assuming results of a bunch of quizzes are kept in the following table, how do you print all
the quizzes' names and their average score (quizName is 'Php Mysql', 'Css Html', 'Web Design'
and so on for other quizzes)?

+--------------+--------------+
| Field       | Type         |
+--------------+--------------+
| userName | varchar(20) |
| userScore | tinyint(3) |
| userComments | varchar(255) |
| quizName | varchar(20) |
+--------------+--------------+
Answer: select quizName, avg(userScore) from tblQuiz group by quizName;

71: Is this quiz table normalized and is that OK?

+--------------+--------------+
| Field       | Type         |
+--------------+--------------+
| userName | varchar(20) |
| userEmail | varchar(20) |
| userScore | tinyint(3) |
| userComments | varchar(255) |
| quizName | varchar(20) |
| quizType | varchar(20) |
| quizUrl       | varchar(20) |


16 | P a g e                                     Pankaj Kumar Jha (www.globaljournals.org)
+--------------+--------------+

Answer: it's not normalized, and that's NOT OK

Explanation: The quiz data (name, type, url) should be moved in a new table because it repeats
itself on many rows. The table that stores results should be linked to this new table by a foreign
key.

72: Which is the correct timeline (OO stands for object oriented)?

   1. OO Programming, OO Analysis, OO Design
   2. OO Analysis, OO Design, OO Programming
Answer: 2

Explanation: First Analysis, then Design, then Programming.

73: What does this output:
class T
{
       public $m = "a";

        function T()
        {
                $this->m = "b";
        }
}

$t = new T();
$p = $t->m;
$p = "c";

echo $t->m;

Answer: b

Explanation: $p = "c"; does not modify the object member.




17 | P a g e                                 Pankaj Kumar Jha (www.globaljournals.org)
Ad

Recommended

PHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail Explanation
Abdul Rahman Sherzad
 
Getting Started with API Security Testing
Getting Started with API Security Testing
SmartBear
 
6.origins genesis of .net technology
6.origins genesis of .net technology
Pramod Rathore
 
Delegates and events in C#
Delegates and events in C#
Dr.Neeraj Kumar Pandey
 
Attacking thru HTTP Host header
Attacking thru HTTP Host header
Sergey Belov
 
Operator overloading
Operator overloading
ramya marichamy
 
PHP and MySQL : Server Side Scripting For Web Development
PHP and MySQL : Server Side Scripting For Web Development
Edureka!
 
Getting Started in Pentesting the Cloud: Azure
Getting Started in Pentesting the Cloud: Azure
Beau Bullock
 
Php and MySQL
Php and MySQL
Tiji Thomas
 
Methods in Java
Methods in Java
Jussi Pohjolainen
 
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Soroush Dalili
 
Cross site scripting
Cross site scripting
n|u - The Open Security Community
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
ENSET, Université Hassan II Casablanca
 
array of object pointer in c++
array of object pointer in c++
Arpita Patel
 
REST API Authentication Methods.pdf
REST API Authentication Methods.pdf
Rubersy Ramos García
 
Employee management system1
Employee management system1
supriya
 
AEM target Integration
AEM target Integration
Kanika Gera
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
Venkateswara Babu Ravipati
 
Software Requirement Analysis and Specification (SRS) of Automated Cyber Cafe...
Software Requirement Analysis and Specification (SRS) of Automated Cyber Cafe...
Misu Md Rakib Hossain
 
Buffer overflow attacks
Buffer overflow attacks
Joe McCarthy
 
Security Testing Training With Examples
Security Testing Training With Examples
Alwin Thayyil
 
03. oop concepts
03. oop concepts
Haresh Jaiswal
 
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
HackIT Ukraine
 
Optional in Java 8
Optional in Java 8
Richard Walker
 
Remote Method Invocation
Remote Method Invocation
Paul Pajo
 
J2EE Architecture Explained
J2EE Architecture Explained
Adarsh Kr Sinha
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
Ramakrishna Reddy Bijjam
 
Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and Answers
Vineet Kumar Saini
 
Practice exam php
Practice exam php
Yesenia Sánchez Sosa
 

More Related Content

What's hot (20)

Php and MySQL
Php and MySQL
Tiji Thomas
 
Methods in Java
Methods in Java
Jussi Pohjolainen
 
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Soroush Dalili
 
Cross site scripting
Cross site scripting
n|u - The Open Security Community
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
ENSET, Université Hassan II Casablanca
 
array of object pointer in c++
array of object pointer in c++
Arpita Patel
 
REST API Authentication Methods.pdf
REST API Authentication Methods.pdf
Rubersy Ramos García
 
Employee management system1
Employee management system1
supriya
 
AEM target Integration
AEM target Integration
Kanika Gera
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
Venkateswara Babu Ravipati
 
Software Requirement Analysis and Specification (SRS) of Automated Cyber Cafe...
Software Requirement Analysis and Specification (SRS) of Automated Cyber Cafe...
Misu Md Rakib Hossain
 
Buffer overflow attacks
Buffer overflow attacks
Joe McCarthy
 
Security Testing Training With Examples
Security Testing Training With Examples
Alwin Thayyil
 
03. oop concepts
03. oop concepts
Haresh Jaiswal
 
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
HackIT Ukraine
 
Optional in Java 8
Optional in Java 8
Richard Walker
 
Remote Method Invocation
Remote Method Invocation
Paul Pajo
 
J2EE Architecture Explained
J2EE Architecture Explained
Adarsh Kr Sinha
 
PYTHON PROGRAMMING NOTES RKREDDY.pdf
PYTHON PROGRAMMING NOTES RKREDDY.pdf
Ramakrishna Reddy Bijjam
 
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Soroush Dalili
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
Développement d'un site web jee de e commerce basé sur spring (m.youssfi)
ENSET, Université Hassan II Casablanca
 
array of object pointer in c++
array of object pointer in c++
Arpita Patel
 
Employee management system1
Employee management system1
supriya
 
AEM target Integration
AEM target Integration
Kanika Gera
 
Software Requirement Analysis and Specification (SRS) of Automated Cyber Cafe...
Software Requirement Analysis and Specification (SRS) of Automated Cyber Cafe...
Misu Md Rakib Hossain
 
Buffer overflow attacks
Buffer overflow attacks
Joe McCarthy
 
Security Testing Training With Examples
Security Testing Training With Examples
Alwin Thayyil
 
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
HackIT Ukraine
 
Remote Method Invocation
Remote Method Invocation
Paul Pajo
 
J2EE Architecture Explained
J2EE Architecture Explained
Adarsh Kr Sinha
 

Viewers also liked (20)

Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and Answers
Vineet Kumar Saini
 
Practice exam php
Practice exam php
Yesenia Sánchez Sosa
 
1000+ php questions
1000+ php questions
Sandip Murari
 
25 php interview questions – codementor
25 php interview questions – codementor
Arc & Codementor
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
iimjobs and hirist
 
Useful functions for arrays in php
Useful functions for arrays in php
Chetan Patel
 
Zend PHP 5.3 Demo Certification Test
Zend PHP 5.3 Demo Certification Test
Carlos Buenosvinos
 
MVC in PHP
MVC in PHP
Vineet Kumar Saini
 
Country State City Dropdown in PHP
Country State City Dropdown in PHP
Vineet Kumar Saini
 
Zend Certification PHP 5 Sample Questions
Zend Certification PHP 5 Sample Questions
Jagat Kothari
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHP
Vineet Kumar Saini
 
Top 100 .Net Interview Questions and Answer
Top 100 .Net Interview Questions and Answer
Vineet Kumar Saini
 
Top 100 SQL Interview Questions and Answers
Top 100 SQL Interview Questions and Answers
iimjobs and hirist
 
Introduction to PHP
Introduction to PHP
Bradley Holt
 
Php mysql ppt
Php mysql ppt
Karmatechnologies Pvt. Ltd.
 
Sql Question #3
Sql Question #3
Kai Liu
 
Dropdown List in PHP
Dropdown List in PHP
Vineet Kumar Saini
 
CSS in HTML
CSS in HTML
Vineet Kumar Saini
 
Browser information in PHP
Browser information in PHP
Vineet Kumar Saini
 
SQL Limit in PHP
SQL Limit in PHP
Vineet Kumar Saini
 
Ad

Similar to PHP Technical Questions (20)

OPEN SOURCE WEB APPLICATION DEVELOPMENT question
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
vishal choudhary
 
PHP Reviewer
PHP Reviewer
Cecilia Pamfilo
 
PHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail Explanation
OXUS 20
 
Php interview questions
Php interview questions
Shubham Sunny
 
Php questions and answers
Php questions and answers
Deepika joshi
 
PHP
PHP
priyadharshini murugan
 
Doc
Doc
KD030303
 
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
fntsofttech
 
501 - PHP MYSQL.pdf
501 - PHP MYSQL.pdf
AkashGohil10
 
Php interview questions
Php interview questions
sekar c
 
FNT Software Solutions Pvt Ltd Placement Papers - PHP Technologies
FNT Software Solutions Pvt Ltd Placement Papers - PHP Technologies
fntsofttech
 
PHP Interview Questions for Freshers 2018
PHP Interview Questions for Freshers 2018
AshokKumar3319
 
Php interview questions with answer
Php interview questions with answer
Soba Arjun
 
Web Technology_10.ppt
Web Technology_10.ppt
Aftabali702240
 
Php tutorial
Php tutorial
Mohammed Ilyas
 
Synapse india complain sharing info about php chaptr 26
Synapse india complain sharing info about php chaptr 26
SynapseindiaComplaints
 
Php5 certification mock exams
Php5 certification mock exams
echo liu
 
Introduction in php
Introduction in php
Bozhidar Boshnakov
 
Mcq ppt Php- array
Mcq ppt Php- array
Shaheen Shaikh
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
Michelangelo van Dam
 
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
OPEN SOURCE WEB APPLICATION DEVELOPMENT question
vishal choudhary
 
PHP Basic and Fundamental Questions and Answers with Detail Explanation
PHP Basic and Fundamental Questions and Answers with Detail Explanation
OXUS 20
 
Php interview questions
Php interview questions
Shubham Sunny
 
Php questions and answers
Php questions and answers
Deepika joshi
 
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
fntsofttech
 
501 - PHP MYSQL.pdf
501 - PHP MYSQL.pdf
AkashGohil10
 
Php interview questions
Php interview questions
sekar c
 
FNT Software Solutions Pvt Ltd Placement Papers - PHP Technologies
FNT Software Solutions Pvt Ltd Placement Papers - PHP Technologies
fntsofttech
 
PHP Interview Questions for Freshers 2018
PHP Interview Questions for Freshers 2018
AshokKumar3319
 
Php interview questions with answer
Php interview questions with answer
Soba Arjun
 
Synapse india complain sharing info about php chaptr 26
Synapse india complain sharing info about php chaptr 26
SynapseindiaComplaints
 
Php5 certification mock exams
Php5 certification mock exams
echo liu
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
Michelangelo van Dam
 
Ad

Recently uploaded (20)

Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 

PHP Technical Questions

  • 1. 1. What does the following code return? $arr = array(1,3,5); $count = count($arr); if ($count = 0) { echo "An array is empty."; } else { echo "An array has $count elements."; } 1. An array has 3 elements. 2. An array consists of 0 elements. 3. An array is empty. Answer: 2 2.What is the result of the following code? $a = 10; if($a > 5 OR < 15) echo "true"; else echo "false"; 1. true 2. false 3. There is a syntax error will display. 4. Nothing will be displayed. Answer: 3 3. Which of the statements is not true of the interfaces? 1. A class can implement multiple interfaces. 2. Methods with the same names and arguments can exist in multiple interfaces, this class implements. 3. An abstract class can implement multiple interfaces. 4. The interface itself can extend multiple interfaces. Answer: 2 4. If you want to pass the argument of the function by reference, the correct path would be: 1. function ModifyReport(&$Rptfile){} 2. function ModifyReport($Rptfile){} 3. function ModifyReport(ByRef $Rptfile){} 4. function ModifyReport(&Rptfile){} Answer: 1 5.Which of the following pairs of operators are not opposite? 1. +, - 2. &=, |= 3. ==, != 4. <<, >> Answer: 2 1|Page Pankaj Kumar Jha (www.globaljournals.org)
  • 2. 6. Which of the following casts are not true? <?php $fig = 23; $varbl = (real) $fig; $varb2 = (double) $fig; $varb3 = (decimal) $fig; $varb4 = (bool) $fig; ?> 1. real 2. double 3. decimal 4. boolean Answer: 3 7. Choose false statement about abstract classes in PHP5. 1. Abstract classes are introduced in PHP5. 2. An abstract method's definition may contain method body. 3. Class with at least one abstract method must be declared as abstract. 4. An abstract class may contain non-abstract methods. Answer: 2 8. Which of the following functions returns the longest hash value? 1. sha1() 2. md5() 3. crc32() 4. All these functions return the same hash value. Answer: 1 9. Which of these characters can be processed by the htmlspecialchars() function? 1. ' - single quote 2. '' - double quote 3. < - less than 4. > - greater than 5. & - an ampersand 6. All Answer: 6 10. Choose all valid PHP5 data types. 1. money 2. varchar 3. float 4. char 5. complex Answer: 3 2|Page Pankaj Kumar Jha (www.globaljournals.org)
  • 3. 11. How many parameters can be passed to this function? <? function f() { ... } ?> 1. 0 (zero) 2. 1 (one) 3. that amount determined by the php configuration. 4. any number of params. Answer: 4 12. What gets printed? <?php $var = 'false'; if ($var) { echo 'true'; } else { echo 'false'; } ?> Answer: true [This is a string literal, which converts to Boolean true ] 13. Which of the following is used to declare a constant 1. const 2. constant 3. define 4. #pragma 5. Def Answer: 3 Here is an example of declaring and using a constant: define(PI, 3.14); printf("PI = %.2fn", PI); 14. What will be printed? <?php $var = '0'; if ($var) { echo 'true'; } else { echo 'false'; } ?> Answer: false 3|Page Pankaj Kumar Jha (www.globaljournals.org)
  • 4. 15. What will be the value of $var? <?php $var = 1 / 2; ?> 1. 0 2. 0.5 3. 1 Answer:2 16. How do we access the value of 'd' later? $a = array( 'a', 3 => 'b', 1 => 'c', 'd' ); 1. $a[0] 2. $a[1] 3. $a[2] 4. $a[3] 5. $a[4] Answer: 5 17. Which of the following is NOT a magic predefined constant? 1. __LINE__ 2. __FILE__ 3. __DATE__ 4. __CLASS__ 5. __METHOD__ Answer: 3 18. What will be printed? $a = array(); if ($a == null) { echo 'true'; } else { echo 'false'; } Answer: true[empty array converts to null ] 19. What will be printed? if (null === false) { echo 'true'; } else { echo 'false'; } Answer: false === is true if values are equal and of the same type, false is of the boolean type, but null is of the special null type 4|Page Pankaj Kumar Jha (www.globaljournals.org)
  • 5. 20. What gets printed? <?php $RESULT = 11 + 011 + 0x11; echo "$RESULT"; ?> 1. 11 2. 22 3. 33 4. 37 5. 39 Answer: 4 [A decimal plus an octal plus a hex number. 11 + 9 + 17 = 37 ] 21. What will be the value of $var below? $var = true ? '1' : false ? '2' : '3'; 1. 1 2. 2 3. 3 Answer: 2[ternary expressions are evaluated from left to right] 22. What will be printed? if ('2' == '02') { echo 'true'; } else { echo 'false'; } Answer: true [Numerical strings are compared as integers] 23. Which of the following is NOT a valid PHP comparison operator? 1. != 2. >= 3. <=> 4. <> 5. === 6. Answer:3 24. What will be printed? $var = 'a'; $VAR = 'b'; echo "$var$VAR"; 1. aa 2. bb 3. ab Answer: 3[Variable names are case-sensitive] 5|Page Pankaj Kumar Jha (www.globaljournals.org)
  • 6. 25. What will be printed? $a = array( null => 'a', true => 'b', false => 'c', 0 => 'd', 1 => 'e', '' => 'f'); echo count($a), "n"; 1. 2 2. 3 3. 4 4. 5 5. 6 Answer: 2[Keys will be converted like this: null to '' (empty string), true to 1, false to 0 ] 26. What gets printed? class MyException extends Exception {} try { throw new MyException('Oops!'); } catch (Exception $e) { echo "Caught Exceptionn"; } catch (MyException $e) { echo "Caught MyExceptionn"; } Answer: Caught Exception [The first catch will match because MyException is a subclass of Exception, so the second catch is unreachable ] 27. What will be printed? $a = array(); if ($a[1]) null; echo count($a), "n"; 1. 0 2. 1 3. 2 4. this code won't work Answer: 1[checking value in if() does not create an array element ] 28. What will be printed by the below code? $a = 1; { $a = 2; } echo $a, "n"; Answer: 2 [PHP variables only have a single scope (except in functions) ] 6|Page Pankaj Kumar Jha (www.globaljournals.org)
  • 7. 29. What gets printed? <?php $str = 'abn'; echo $str; ?> 1. ab(newline) 2. ab(newline) 3. abn 4. ab(newline) 5. abn Answer: 3 [ is a special case in single-quoted string literals, which gives a single , n is not interpolated in single- quoted string literals ] 30. Which statement about the code below is correct? class A {} class B {} class C extends A, B {} 1. the code is perfectly fine 2. classes can not be empty 3. class C can not extend both A and B 4. qualifiers 'public' or 'private' are missing in class definitions Answer: 3 [A class can only inherit one base class ] 31. What gets printed? <?php $x=array("aaa","ttt","www","ttt","yyy","tttt"); $y=array_count_values($x); echo $y[ttt]; ?> a)2 b)3 c)1 d)4 Answer: a eg: <?php $array = array(1, "hello", 1, "world", "hello"); print_r(array_count_values($array)); ?> After execution of above script we will get output: Array 7|Page Pankaj Kumar Jha (www.globaljournals.org)
  • 8. ( [1] => 2 //1 came two times in array [hello] => 2 //Hello came two times in array [world] => 1 ) 32. What's the best way to copy a file from within a piece of PHP? 1. Print out a message asking your user to "telnet" in to the server and copy the file for you 2. Open the input and output files, and use read() and write() to copy the data block by block until read() returns a zero 3. Use the built in copy() function 4. Use "exec" to run an operating system command such as cp (Unix, Linux) or copy (Windows) Answer: 3 33. In php Which method is used to getting browser properties? 1. $_SERVER['HTTP_USER_AGENT']; 2. $_SERVER['PHP_SELF'] 3. $_SERVER['SERVER_NAME'] 4. $_SERVER['HTTP_VARIENT'] Answer: 1 34. Assume that your php file 'index.php' in location c:/apache/htdocs/phptutor/index.php. If you used $_SERVER['PHP_SELF'] function in your page, then what is the return value of this function ? 1. phptutor/index.php 2. /phptutor/index.php 3. c:/apache/htdocs/phptutor/index.php 4. index.php Answer: 2 35. What will be the ouput of below code ? Assume that today is 2009-5-19:2:45:32 pm <?php $today = date("F j, Y, g:i a"); ?> 1. May 19,09,2:45:32 PM 2. May 19, 2009, 2:45 pm 3. May 19,2009,14:45:32 pm 4. May 19,2009,14:45:32 PM 8|Page Pankaj Kumar Jha (www.globaljournals.org)
  • 9. Answer: 2 36. What function used to print statement in PHP? 1. echo(); 2. printf 3. " Answer: 1 37. <?php define("x","5"); $x=x+10; echo x; ?> 1. Error 2. 15 3. 10 4. 5 Answer: 4 38. PHP variables are 1. Multitype variables 2. Double type variables 3. Single type variable 4. Trible type variables Answer: 1 39. Which of these statements is true? 1. PHP interfaces to the MySQL database,and you should transfer any data in Oracle or Sybase to MySQL if you want to use PHP on the data. 2. PHP interfaces to a number of relational databases such as MySQL, Oracle and Sybase. A wrapper layer is provided so that code written for one database can easily be transferred to another if you later switch your database engine. 3. PHP interfaces to a number of relational databases such as MySQL, Oracle and Sybase but the interface differs in each case. 4. There's little code in PHP to help you interface to databases, but there's no reason why you can't write such code if you want to. Answer: 3 40. Which of the following is used to check if a function has already been defined? 1. bool function_exists(functionname) 2. bool f_exists(functionname) 3. bool func_exist(functioname) Answer: 1 9|Page Pankaj Kumar Jha (www.globaljournals.org)
  • 10. 41. Assume that your php file 'index.php' in location c:/apache/htdocs/phptutor/index.php. If you used basename($_SERVER['PHP_SELF']) function in your page, then what is the return value of this function ? 1. phptutor 2. phptutor/index.php 3. index.php 4. /index.php Answer: 3 42. Below program will call the function display_result() ? <?php $x="display"; ${$x.'_result'} (); ?> 1. False 2. True 3. Parser Error 4. None of the above Answer: 2 43. What gets printed? <?php $str="3dollars"; $a=20; $a+=$str; print($a); ?> 1. 23dollars 2. 203dollars 3. 320dollars 4. 23 Answer: 4 44. What gets printed? <?php function zz(& $x) { $x=$x+5; } ?> $x=10; 10 | P a g e Pankaj Kumar Jha (www.globaljournals.org)
  • 11. zz($x); echo $x; 1. 5 2. 0 3. 15 4. 10 Answer: 3 45. What is the following output? <?php $x=dir("."); while($y=$x->read()) { echo $y." " } $y->close(); ?> 1. display all folder names 2. display a folder content 3. display content of the all drives 4. Parse error Answer: 2 46. <?php $test="3.5seconds"; settype($test,"double"); settype($test,"integer"); settype($test,"string"); print($test); ?> What is the following output? 1. 3.5 2. 3.5seconds 3. 3 4. 3second Answer: 3 47. PHP is 1. Partially cross-platform 11 | P a g e Pankaj Kumar Jha (www.globaljournals.org)
  • 12. 2. Truly cross-platform 3. None of above Answer: 2 48. PHP is a _____ . It means you do not have to tell PHP which data type the variable is.PHP automatically converts the variable to the correct data type, depending on its value. 1. client side language 2. local language 3. global language 4. loosely typed language Answer: 4 49. Which of the following function is used to change the root directory in PHP? 1. choot() 2. change_root() 3. cd_root() 4. cd_r() Answer: 1 50. The PHP syntax is most similar to: 1. PERL and C 2. Java script 3. VB Script 4. Visual Basic Answer: 1 51. What will be the output of below code ? <?php $arr = array(5 => 1, 12 => 2); $arr[] = 56; $arr["x"] = 42; echo var_dump($arr); ?> 1. 42 2. array(3) { [12]=> int(2) [13]=> int(56) ["x"]=> int(42) } 3. array(4) { [5]=>int(1) [12]=> int(2) [13]=> int(56) ["x"]=> int(42) } 4. 1,2,56,42 Answer: 3 52. What is the output of the following PHP script? 12 | P a g e Pankaj Kumar Jha (www.globaljournals.org)
  • 13. <?php define('SOMEVAL', 0); if (strlen(SOMEVAL) > 0) { echo "Hello"; } else { echo "Goodbye"; } ?> 1. Goodbye 2. Hello 3. Syntax Error Answer: 53. Consider the following PHP code: <?php $myArray = array( 10, 20, 30, 40 ); ?> What is the simplest way to return the values 20 and 30 in a new array without modifying $myArray? 1. array_slice($myArray, 1, 2); 2. array_splice($myArray, 2, 1); 3. array_slice($myArray, 2, 1); 4. array_slice($myArray, 10, 20); Answer: 54. What will this output <?php $a = false; $b = true; $c = false; if ($a ? $b : $c) { echo "false"; } else { echo "true"; } ?> 13 | P a g e Pankaj Kumar Jha (www.globaljournals.org)
  • 14. Answer: true Explanation: If $a is true, then $b will be evaluated; otherwise (as is the case here) $c will be evaluated. As $c is false, the conditional evaluates as false, and the script (confusingly) prints true. 55: What can you use to replace like with hate in I like Regular Expressions? Answer: preg_replace("/like/", "hate", "I like Regular Expressions") Explanation: The search is a regular expression and it has slashes around it, the replace isn't, so it doesn't have any slashes. 56. What library do you need in order to process images? Answer. GD library 57. What function sends mail: Answer: imap_mail, mail 58: What is the problem with <?=$expression ?> ? Answer: It requires short tags and this is not compatible with XML Explanation: If you have short_open_tag On then this XML <?xml version="1.0" encoding="utf- 8"?> (for example) will be parsed by the PHP engine, causing both a PHP and a XML parsing error. 59: Put this line php display_errors=false in a .htaccess file when you deploy the application? Answer: That won't hide any error 'coz it's not the correct code Explanation: I would have said 'Good idea, increases security', but wait a minute... the correct syntax is php_flag display_errors Off ... 60. Which of the following regular expressions will match the string go.go.go? Answer: ........ Explanation: Any character (twice) followed by a period followed by any character (twice) followed by ... 61: A constructor is a special kind of _______________ Answer: Method Explanation: It is a function, but since it's in a class we call it a method. 14 | P a g e Pankaj Kumar Jha (www.globaljournals.org)
  • 15. 62: What does break; do? Answer: Ends execution of the current for, foreach, while, do-while or switch structure Explanation: Yup. If you were tempted to say 'moves on to the next iteration', that's the continue statement. 63: Can this PHP code be valid: $4bears = $bears->getFirst4(); Answer: No Explanation: A variable name can't start with a number. Don't ask me why not, I don't see any reason why it shouldn't; it's probably some carry over from C. 64. What will this output: <?php $dog = "Dogzilla"; $dragon = &$dog; $dragon = "Dragonzilla"; echo $dog." "; echo $dragon; ?> Answer: Dragonzilla Dragonzilla Explanation: $dragon is really $dog, it just has a different name. 65: Assuming all the variables a, b, c have already been defined, could this be a variable name: ${$a}[$b][$c] ? Answer: Yes Explanation: Yup, it's a multidimensional array. 66: In MySQL, if you want to find out about the structure of a table tblQuiz, what will you use? Answer: DESCRIBE tblQuiz 67: In which of the following scenarios might you use the function md5? 1. perform large number multiplication 2. perform authentication without unnecessarily exposing the access credentials Answer: 2 15 | P a g e Pankaj Kumar Jha (www.globaljournals.org)
  • 16. Explanation: md5 returns an unique hash string for the string you pass it; if you have only the hash it's practically impossible to find the string that produces it. 68: What does this function do: <?php function my_func($variable) { return (is_numeric($variable) && $variable % 2 == 0); } ?> Answer: tests whether $variable is an even number Explanation: It returns true if $variable is divisible by 2. 69: How do you find the square root of a number? Answer: In both PHP and MySQL you have a function called sqrt 70: Assuming results of a bunch of quizzes are kept in the following table, how do you print all the quizzes' names and their average score (quizName is 'Php Mysql', 'Css Html', 'Web Design' and so on for other quizzes)? +--------------+--------------+ | Field | Type | +--------------+--------------+ | userName | varchar(20) | | userScore | tinyint(3) | | userComments | varchar(255) | | quizName | varchar(20) | +--------------+--------------+ Answer: select quizName, avg(userScore) from tblQuiz group by quizName; 71: Is this quiz table normalized and is that OK? +--------------+--------------+ | Field | Type | +--------------+--------------+ | userName | varchar(20) | | userEmail | varchar(20) | | userScore | tinyint(3) | | userComments | varchar(255) | | quizName | varchar(20) | | quizType | varchar(20) | | quizUrl | varchar(20) | 16 | P a g e Pankaj Kumar Jha (www.globaljournals.org)
  • 17. +--------------+--------------+ Answer: it's not normalized, and that's NOT OK Explanation: The quiz data (name, type, url) should be moved in a new table because it repeats itself on many rows. The table that stores results should be linked to this new table by a foreign key. 72: Which is the correct timeline (OO stands for object oriented)? 1. OO Programming, OO Analysis, OO Design 2. OO Analysis, OO Design, OO Programming Answer: 2 Explanation: First Analysis, then Design, then Programming. 73: What does this output: class T { public $m = "a"; function T() { $this->m = "b"; } } $t = new T(); $p = $t->m; $p = "c"; echo $t->m; Answer: b Explanation: $p = "c"; does not modify the object member. 17 | P a g e Pankaj Kumar Jha (www.globaljournals.org)