Wednesday, December 30, 2015

php












  1. What will be the output?
<?php
 $i=0;
While($i<=10) {
If ($i<=5) {
Continue;
}
Print $i;
$i=$i+1;
}
?>  
  1. 1
  2. Infinitive
  3. 5
  4. 10

  1. Write the output.
<?php
$str= "good";
$$str= "bye";
echo ${$str };
?>
  1. good
  2. good bye
  3. bye
  4. nothing

  1. <?php
$val1="good";
$val2=&$val1;
$val2="bad";
?>
What is the $val1?
  1. good
  2. bad
  3. good bad
  4. all

  1. What will be the output?
<?php
$a="1";
If($a==1) {
Print "sonna is funny";
}
elseif($a=="1") {
Print "sonna is jolly ";
} else {
Print "sonna is gomvir";
}
?>
    1. sonna is gomvir
    2. sonna is jolly
    3. sonna is funny
    4. None of the above

  1. What will be the output?
<?php
$i=0;
While ($i<=10) {
    If ($i<=5) {
    break;
    }
Print $i;
$i=$i+2;
}
?>
    1. 5
    2. 10
    3. 2
    4. nothing

  1. What will be the output?
<?php
$i=1;
do {
$i++;
Print $i;
}
While ($i<=0);
?>
    1. 1
    2. 2
    3. 0
    4. none of the above

  1. $price = 10; $tax = 5;
function calcSalesTax($price, $tax)
{
$total = $price + ($price * $tax); }

echo "Total cost: $total";

What is the output?
  1. Total cost: 50
  2. Total cost: 30
  3. Total cost: 60
  4. Total cost: 70

  1. function calcSalesTax($price, $tax=.03)
{
$total = $price + ($price * $tax);
echo "Total cost: $total";
}

$price = 10;

calcSalesTax($price);

What is output?
  1. Total cost: 10.50
  2. Total cost: 10.20
  3. Total cost: 10.30
  4. Error

  1. Write the output of the following code?
<?php
Function add()
{
STATIC $n=5;
$n=$n+5;
echo $n;
}
add();
?>
  1. 5
  2. 55
  3. 10
  4. None of the above

  1. <?php
    function zz(& $x) {
    $x=$x+5;
    }
    ?>
    $x=10;
    zz($x);
    echo $x; ?>
      1. 5
      2. 0
      3. 15
      4. 10

  1. What is output?
<?php
Function a($a="",$b=10)
{
$d=$a + $b;
Print $d;
}
a(30,40);
?>
    1. 30
    2. 40
    3. ""40
    4. 70

  1. What is output?
<?php
function sonna($a,$b) {
    function sonu($c) {
        $g=  $c*.76;
        return($g);
        }
$tot=$a+$b;
print sonu($tot);       
}       
sonna(5,6);
?>
    1. 8.36
    2. 5
    3. 6
    4. 9.36


  1. Write the output of the following code?
Function add() {
STATIC $n=5;
$n=$n+5;
echo $n;
}
add(); ?>
  1. 5
  2. 5+5
  3. 10
  4. $n
  1. Which is the maximum number according to sort of the following..
10, 5,7,20, 3
      1. 20
      2. 10
      3. 5
      4. 7

  1. $colors = array("red","blue","green");
list($red, $blue, $green) = $colors;

echo $red . " is one of Element of " .'$colors';

  1. red is one of Element of $colors
  2. red is one of Element of $days
  3. red is one of Element of colors
  4. Notice: Undefined variable


  1. $numbers = range(1, 6);

Print_r($numbers);

What is output?

  1. Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 )
  2. Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 [5] => 7 )
  3. Array ( [1] => 0 [2] => 1 [3] => 2 [4] => 3 [5] => 4 [6] => 6 )
  4. Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )

  1. $states = array("Ohio", "New York");
array_push($states, "California", "Texas");

What is the current status of $states?
  1. array("California", "Texas", "Ohio", "New York")
  2. array("Ohio", "New York", “California", "Texas")
  3. array("California", "Texas”)
  4. array("California", "Ohio", "New York")

  1. — creates an array by using one array for keys and another for its values
A. Array_Splice  
B. array_merge
C. Array_Fill()
D. array_combine



  1. <?php
    $stack = array("orange", "banana", "apple", "raspberry");
    $fruit = array_pop($stack);
    print_r($stack);
    ?>
What will be the output?
    1. [0] => orange    [1] => banana    [2] => apple
    2. [0] => orange    [1] => banana    [2] => raspberry
    3. [0] => raspberry [1] => banana    [2] => apple

  1. <?php
    $array = array("size" => "XL", "color" => "gold");
    print_r(array_values($array));
    ?>
What will be the output?
A. [0] => XL    [1] => gold  [2]=>Size
B. [0] => XL    [1] => gold



  1. What is the output?
<?php
$array = array(10,20,10,30,20,40,20,40);
$a =array_count_values($array);
print_r($a);
?>
(a)   Array ( [2] => 10 [3] => 20 [1] => 30 [2] => 40 )
(b)   Array ( [0] => 10 [1] => 20 [2] => 10 [3] => 30[4] => 20[5] => 40[6] => 20[7] => 40)
(c)    Array ( [10] => 2 [20] => 3 [30] => 1 [40] => 2 )
(d)    none of the above


  1. <?php
    $color=array("red","yellow","white");
    $x=in_array("black",$color);
    if($x==0)
    echo "good bye";
    if($x==1) echo "Hello";
    ?>
  1. Hello
  2. Error
  3. good bye
  4. None of the above


  1. Which of the following is/are the example(s) of compound data type?
(a)   $a[0]=4.765
(b)   $a=4
(c)    $$a=4.77
(d)    None

  1. What is the output?
<?php
$array = array(10,20, 30, 40);
print_r(array_pad($array,-8,0));
?>
(a)   [0]=> 0, [1]=> 0, [2]=> 0, [3]=> 0, [4]=> 10, [5]=> 20, [6]=> 30, [7]=> 40
(b)   [0]=> 10, [1]=> 20, [2]=> 30, [3]=> 40, [4]=> 0, [5]=> 0, [6]=> 0, [7]=> 0
(c)    [0]=> 10, [1]=> 20, [2]=> 0, [3]=> 0, [4]=> 0, [5]=> 0, [6]=> 30, [7]=> 40
(d)    none of the above


  1. Which one of the following terms must relate to "Object"
A. Static allocation.
B. Specific instance of the class models.
C. Code component.
D. Attributes of a class.


  1. A constructor is used to...
A. Free memory.
B. Initialize a newly created object.
C. Import packages.
D. Create a JVM for applets.

  1. What is the purpose of the Properties?
A. To build a user interface.
B. To build Object
C. to describe some aspect of a class.
D. Noe of the Above


  1. Which of the following statements are true about constructors?
A. Constructor is defined as block of code that automatically executes at the time of object instantiation.
B.  Constructor can accept parameters.
C. Constructor ensures that the object being passed to the method.
B. Class constructors cannot call on other constructors.


  1. What are the two common characteristics shared by all objects?
  1. Methods and interfaces
  2. State and behavior
  3. Methods and messages


  1. Which option is false for constructor?
  1. can accept parameter
  2. can call other method
  3. can call other constructor
  4. None of the above


  1. Which option(s) is/are true for object oriented programming?
A. Code reusability                     B. Data hiding.
C. Support multiple inheritances.
D. All


  1. Which statement is/are true about Exception Handling?
A. Definition of error.
B. Exceptions are used to change the normal flow of a script if a specified error occurs.
C. Exceptions should only be used with error conditions



  1. Which statement is true about Regular Expressions?
    1. describing or matching data according to defined syntax rules
    2. allowing to slice and dice text in nearly every conceivable fashion.
    3. Used for searching data


  1. How to get the file size, in bytes of the file uploaded from the client Machine?
  1. A.$_Files[‘userfile’]_size Variable
  2. B.$_Files[‘userfile’][‘size’] variable
  3. C.$_Files[‘size’][‘tempname’]
  4. All of them

  1. Which of the following function determine whether a file specified by the input parameters filename is uploaded using the post method?
  1. Uploaded_file()
  2. File_uploaded()
  3. Is_uploaded_file()
  4. None of them

  1. To send a mail, Which of the following statement should be used?
  1. Send_mail("test@example.com", "This is a subject", "This is the mail body")
  2. mail("test@example.com", "This is a subject", "This is the mail body")
  3. mailto:("test@example.com", "This is a subject", "This is the mail body")


  1. What is cookie?
(a)   The practices of storing kilobits of information on the client machine in what are commonly called cookie.
(b)   The practices of storing gigabytes of information on the server machine. in what are commonly called cookie.
(c)    The practices of storing information on the client machine. in what are commonly called cookie.
(d)    The practices of storing bits of information on the client's machine in what are commonly called cookie.

  
  1. Which one of the following statements is true for include_once() and require_once()?
    a) Both are exactly the same.
    b) include_once is used for files where as require_once() is not.
    c) Both Handle the errors in the same way.
    d) Both do not handle the errors in the same way.

  1. Say you want to report error concerned about fatal run-time, fatal compile-time error and core error which statement would you use?
    a) error_reporting = E_ALL
    b) error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR
    c) error_reporting = E_ERROR | E_COMPILE_WARNING | E_CORE_ERROR
    d) error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR
  2. What will be the output of the following PHP code?
<?php
   $foods = array("pasta", "steak", "fish", "potatoes");
   $food = preg_grep("/^s/", $foods);
   print_r($food);
   ?>
  1. Array ( [0] => pasta [1] => steak [2] => fish [3] => potatoes )
    b) Array ( [3] => potatoes )
    c) Array ( [1] => steak )
    d) Array ( [0] => potatoes )
  1. What will be the output of the following PHP code?
   <?php
   echo str_pad("Salad", 5)." is good.";
   ?>
a) SaladSaladSaladSaladSalad is good
b) is good SaladSaladSaladSaladSalad
c) is good Salad
d) Salad is good

  1. Which one of the following functions finds the last occurrence of a string, returning its numerical position?
    a) strlastpos()
    b) strpos()
    c) strlast()
    d) strrpos()

  1. What will be the value of the variable $input in the following PHP code?
<?php
$input = "Swapna<td>Lawrence</td>you are really<i>pretty</i>!";
 $input = strip_tags($input,"<i></i>");
   ?>
a) Swapna Lawrence you are really pretty!
b) Swapna <td>Lawrence</td> you are really<i>pretty</i>!
c) Swapna <td>Lawrence</td> you are really pretty!
d) Swapna Lawrence you are really<i>pretty</i>!


  1. To validate an e-mail address, which flag is to be passed to the function filter_var()?
    a) FILTER_VALIDATE_EMAIL
    b) FILTER_VALIDATE_MAIL
    c) VALIDATE_EMAIL
    d) VALIDATE_MAIL

  1. How many validation filters like FILTER_VALIDATE_EMAIL are currently available?
    a) 5
    b) 6
    c) 7
    d) 8

  1. Which function is useful when you want to output the executed command’s result?
    a) out_cmm()
    b) out_system()
    c) cmm()
    d) system()

  1. What will be the output of the following PHP code?
   <?php
   $name = "What is your name?"
   if (preg_match("/name/"),$name)
   echo "My name is Will Pitt ";
   else
   echo "My name is not Will Pitt ";
   if (preg_match("/are/"))
   echo "I am great"
   else
   echo "I am not great";    
   ?>
a) My name is Will Pitt I am great
b) My name is not Will Pitt I am great
c) My name is Will Pitt I am not great
d) My name is not Will Pitt I am not great

  1. Which one of the following is not a preg PHP function?
    a) preg_match
    b) preg_match_all
    c) preg_matchall
    d) preg_split

  1. What will be the output of the following PHP code?
<?php
   $str = "Hello! My name is Cameron Fox. Coffee?";
   $find = array('/is/','/coffee/');
   $replace = array('/was/','/tea/');
   echo preg_replace ($find, $replace, $str);
   ?>

a) Hello! My name was Cameron Fox. tea?
b) Hello! My name is Cameron Fox. tea?
c) Hello! My name is Cameron Fox. Coffee?
d) Hello! My name was Cameron Fox. Coffee?


  1. What will be the output of the following PHP code?

<?php
   $name = "What is your name?"
   if (preg_match("/name/"),$name)
   echo "My name is Will Pitt ";
   else
   echo "My name is not Will Pitt ";
   if (preg_match("/are/"))
   echo "I am great"
   else
   echo "I am not great";    
   ?>

a) My name is Will Pitt I am great
b) My name is not Will Pitt I am great
c) My name is Will Pitt I am not great
d) My name is not Will Pitt I am not great



Descriptive Question

  1. What is the difference between Session and Cookie?
  2. What Is an Array? How to output an array?
  3. What are constructor and destructor?
  4. Difference between w, r, a and a+ mode of file?
  5. Difference between array_merge() and array_combine()?
  6. Explain the parameters of PHP’s mail function.
  7. What are encoding and decoding?
  8. How many ways session handling can be done?
  9. What is HTTP Authentication?
  10. What are the benefits of using PEAR? Or, what is PEAR? What is the benefit of using pear?
  11. What are the different functions in sorting an array? Discuss them?
  12. Which functions are used to add and remove array elements?
  13. What are class and object?
  14. What is regular expression?
  15. Define exceptions?

No comments:

Post a Comment