My Report

PHP Programming Mock Test 5


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

1. Which one of the following preg PHP function is used to do a find and replace on a string or an array?

Question 1 of 10

Question 2 of 10

2. Which one of the following preg PHP functions is used to take a string, and put it in an array?

Question 2 of 10

Question 3 of 10

3. Which characters is used to access property variables on an object-by-object basis?

Question 3 of 10

Question 4 of 10

4. Before you try to process the file, you need to make sure that your $err value is equivalent to _________

Question 4 of 10

Question 5 of 10

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

<?php
class MyClass
{
}

$a = new MyClass;
var_dump(!($a instanceof stdClass));
?>

Question 5 of 10

Question 6 of 10

6. What should be used to refer to a method in the context of a class rather than an object you use?

Question 6 of 10

Question 7 of 10

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

<?php
interface MyInterface
{
}

class MyClass implements MyInterface
{
}

$a = new MyClass;

var_dump($a instanceof MyClass);
var_dump($a instanceof MyInterface);
?>

Question 7 of 10

Question 8 of 10

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

<?php
    class ShopProductWriter
    {
        public function write( $shopProduct )
        {
            $str = "{$shopProduct->title}: " .$shopProduct->getProducer() ." ({$shopProduct->price})\n";
            print $str;
        }
    }
    $product1 = new ShopProduct( "My Antonia", "Willa", "Cather", 5.99 );
    $writer = new ShopProductWriter();
    $writer->write( $product1 );
?>

Question 8 of 10

Question 9 of 10

9. Which one of the following statements instantiates the mysqli class?

Question 9 of 10

Question 10 of 10

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

<?php
class ParentClass
{
}

class MyClass extends ParentClass
{
}

$a = new MyClass;

var_dump($a instanceof MyClass);
var_dump($a instanceof ParentClass);
?>

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.