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

More Related Content

What's hot (20)

Web Application Technologies
Web Application TechnologiesWeb Application Technologies
Web Application Technologies
Se-Han Lee
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Vineeta Garg
 
Pseudocode
PseudocodePseudocode
Pseudocode
Harsha Madushanka
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
shreesenthil
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 
Generics in java
Generics in javaGenerics in java
Generics in java
suraj pandey
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 
PHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerPHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP Server
Rajiv Bhatia
 
php
phpphp
php
ajeetjhajharia
 
Operator.ppt
Operator.pptOperator.ppt
Operator.ppt
Darshan Patel
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
Amit Tyagi
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
sai tarlekar
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
ismailmrribi
 
Python Programming
Python ProgrammingPython Programming
Python Programming
Saravanan T.M
 
Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8
Victor Rentea
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
Computer Hardware & Trouble shooting
 
Sql Injection attacks and prevention
Sql Injection attacks and preventionSql Injection attacks and prevention
Sql Injection attacks and prevention
helloanand
 
Web Application Technologies
Web Application TechnologiesWeb Application Technologies
Web Application Technologies
Se-Han Lee
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 
PHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerPHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP Server
Rajiv Bhatia
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
Amit Tyagi
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
ismailmrribi
 
Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8
Victor Rentea
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Sql Injection attacks and prevention
Sql Injection attacks and preventionSql Injection attacks and prevention
Sql Injection attacks and prevention
helloanand
 

Viewers also liked (20)

Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersTop 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and Answers
Vineet Kumar Saini
 
Practice exam php
Practice exam phpPractice exam php
Practice exam php
Yesenia Sánchez Sosa
 
1000+ php questions
1000+ php questions1000+ php questions
1000+ php questions
Sandip Murari
 
25 php interview questions – codementor
25 php interview questions – codementor25 php interview questions – codementor
25 php interview questions – codementor
Arc & Codementor
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 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 phpUseful 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 TestZend PHP 5.3 Demo Certification Test
Zend PHP 5.3 Demo Certification Test
Carlos Buenosvinos
 
MVC in PHP
MVC in PHPMVC in PHP
MVC in PHP
Vineet Kumar Saini
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry 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 QuestionsZend 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 PHPAdd 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 AnswerTop 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 AnswersTop 100 SQL Interview Questions and Answers
Top 100 SQL Interview Questions and Answers
iimjobs and hirist
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Bradley Holt
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
Karmatechnologies Pvt. Ltd.
 
Sql Question #3
Sql Question #3Sql Question #3
Sql Question #3
Kai Liu
 
Dropdown List in PHP
Dropdown List in PHPDropdown List in PHP
Dropdown List in PHP
Vineet Kumar Saini
 
CSS in HTML
CSS in HTMLCSS in HTML
CSS in HTML
Vineet Kumar Saini
 
Browser information in PHP
Browser information in PHPBrowser information in PHP
Browser information in PHP
Vineet Kumar Saini
 
SQL Limit in PHP
SQL Limit in PHPSQL Limit in PHP
SQL Limit in PHP
Vineet Kumar Saini
 
Ad

Similar to PHP Technical Questions (20)

Php questions and answers
Php questions and answersPhp questions and answers
Php questions and answers
Deepika joshi
 
lab4_php
lab4_phplab4_php
lab4_php
tutorialsruby
 
lab4_php
lab4_phplab4_php
lab4_php
tutorialsruby
 
Web Technology_10.ppt
Web Technology_10.pptWeb Technology_10.ppt
Web Technology_10.ppt
Aftabali702240
 
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP TechnologyFnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
fntsofttech
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
 
php AND MYSQL _ppt.pdf
php AND MYSQL _ppt.pdfphp AND MYSQL _ppt.pdf
php AND MYSQL _ppt.pdf
SVN Polytechnic Kalan Sultanpur UP
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
Vineet Kumar Saini
 
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptxPHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
kamalsmail1
 
Mcq ppt Php- array
Mcq ppt Php- array Mcq ppt Php- array
Mcq ppt Php- array
Shaheen Shaikh
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
Sanketkumar Biswas
 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
AbhishekSharma2958
 
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
Damien Seguy
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
chartjes
 
PHP Reviewer
PHP ReviewerPHP Reviewer
PHP Reviewer
Cecilia Pamfilo
 
PHP Conference Asia 2016
PHP Conference Asia 2016PHP Conference Asia 2016
PHP Conference Asia 2016
Britta Alex
 
JavaScript Array Interview Questions PDF By ScholarHat
JavaScript Array Interview Questions PDF By ScholarHatJavaScript Array Interview Questions PDF By ScholarHat
JavaScript Array Interview Questions PDF By ScholarHat
Scholarhat
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4
Jeff Carouth
 
PHP - Web Development
PHP - Web DevelopmentPHP - Web Development
PHP - Web Development
Niladri Karmakar
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
Iftekhar Eather
 
Php questions and answers
Php questions and answersPhp 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 TechnologyFnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
fntsofttech
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
 
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptxPHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
kamalsmail1
 
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
Damien Seguy
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
chartjes
 
PHP Conference Asia 2016
PHP Conference Asia 2016PHP Conference Asia 2016
PHP Conference Asia 2016
Britta Alex
 
JavaScript Array Interview Questions PDF By ScholarHat
JavaScript Array Interview Questions PDF By ScholarHatJavaScript Array Interview Questions PDF By ScholarHat
JavaScript Array Interview Questions PDF By ScholarHat
Scholarhat
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4
Jeff Carouth
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
Iftekhar Eather
 
Ad

Recently uploaded (20)

Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 

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)