In the following PHP code, what is/are the properties? [code] <?php class Example { public $name; function Sample()

In the following PHP code, what is/are the properties?
Code:
    <?php
    class Example 
    {
        public $name;
        function Sample()
        {
            echo "This is an example";
        }
    } 
    ?>
A. echo “This is an example”;
B. public $name;
C. class Example
D. function sample()
 
Answer: b
Explanation: Above code is an example of ‘classes’ in PHP. Classes are the blueprints of objects. Classes are the programmer-defined data type, which includes the local methods and the local variables. Class is a collection of objects which has properties and behaviour.
 

Tìm kiếm

Back
Top