PHP Assessment

PHP Assessment

  1. How do you declare a variable in PHP?

    a) $x = 10; b) variable x = 10; c) let x = 10;
  2. What is the output of the following PHP code snippet?

                            $x = 10;
                            echo gettype($x);
                            $x = "hello";
                            echo gettype($x);
                        
    a) integer and string b) string and integer c) integer and integer
  3. Which PHP loop is used to iterate over a range of values?

    a) for b) while c) foreach
  4. In PHP, what is used to handle error conditions and exceptions?

    a) try b) catch c) finally
  5. What keyword is used in PHP to throw an exception manually?

    a) throw b) try c) exception
  6. Which PHP function is used for input and output operations?

    a) echo b) print c) fopen
  7. In which programming language is PHP primarily implemented?

    a) C++ b) Java c) PHP
  8. What will be the output of the following PHP code?

                            $a = array(1, 2, 3);
                            $b = $a;
                            $b[0] = 5;
                            echo implode(" ", $a);
                        
    a) 1 2 3 b) 5 2 3 c) 1 5 3