1. Question: Consider the following script. Which PHP function best approximates its behaviour?
    <?php
    function my_funct ($file_name, $data)
    {
        $f = fopen ($file_name, 'w');
        fwrite ($f, $data);
        fclose ($f);
    }
    ?>
    [

    A
    file_get_contents()

    B
    file_put_contents()

    C
    There is no equivalent function in PHP

    D
    file()

    E
    fputs()

    Note: The script in this question best approximates the way file_put_contents() works; however, this function does not exist in PHP 4, having been introduced with PHP 5. Therefore, Answer C is correct.
    1. Report
  2. Question: What should you do if your script is having problem recognizing file endings from a text file saved on a platform different from the one you’re reading it on?

    A
    Change the auto_detect_line_endings INI setting

    B
    Use a regular expression to detect the last letter of a line

    C
    Use fpos()

    D
    Use ftok()

    E
    Read the file one character at a time

    Note: The auto_detect_line_endings php.ini setting was introduced in PHP 4.3.0 to make the system attempt to automatically detect the type of line endings used when saving a text file. Therefore, Answer A is correct.
    1. Report
  3. Question: Which of the following equivalence operations evaluates to true if the two operands are not of the same data type or do not have the same value?

    A
    !==

    B
    ===

    C
    !=

    D
    ==

    Note: Not available
    1. Report
  4. Question: Consider the following code:
    <?php   
        $a=5;
        $b=12;
        $c=10;
        $d=7;
        $e=($a*$<img src="http://vcampus.co/images/emotions/facebook_emotions/fbglasses.png" title="Glasses" alt="Glasses" />+$c*$d/$a;
        print($e);
    ?>

    A
    154

    B
    74

    C
    26

    D
    130

    Note: The output of the given code will be produced in the following steps: 1. The value of a and b will be multiplied, i.e., ($a*$b)=60. 2. The value of c and d will be multiplied, i.e., $c*$d=70. 3. The product of c and d will be divided by a, i.e., 70/5=14. 4. The quotient obtained will be added to the product of a and b, i.e., 14+60=74.
    1. Report
  5. Question: You work as a Web Developer for Remote Inc. What will be the output when you try to run the script below?
    <?php
        $b = false;
        if($b = true)
          print("true");
        else
          print("false");
    ?>

    A
    false

    B
    true

    C
    The script will throw an error message.

    D
    true false

    Note: Not available
    1. Report
  6. Question: Which of the following options is/are correct regarding variable scopes in PHP?

    A
    script, function and class

    B
    class, global and script

    C
    global, function and class

    D
    global, script and function

    Note: Explanation: Global, function and class scope are the three variable scopes for PHP. Variable scope describes where in a program's text the variable may be used, while the extent (or lifetime) describes when in a program's execution a variable has a value. PHP has three types of variable scopes: 1. Function Scope: Variable scope exists within the function where the variable was defined. 2. Global Scope: Variable scope exists everywhere in the PHP script. 3. Class Scope: Variable scope exists within a class where the variable was defined.
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd