Classes Flashcards

1
Q

What function is used to retrieve all defined functions in an array?

A

get_defined_function(void);

Returns array of all functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What function is used to get class methods names?

A

get_class_method(mixed $class_name)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you check existence of method?

A

Use an method_exists(, ). Returns Boolean result

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What function is used to retrieve list of declared classes names ?

A

Use get_declared_classes()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between interface constants and class constants?

A

Interface constants can not be overridden by child unlike class constants.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What function can you use to check if a class exists?

A
Use class_exists(), 
Which returns Boolean
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you call a class automatically which has not previously been defined?

A

Use _autoload() function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What function would you use to get array of given properties for an object?

A

Use get_objects_vars()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you iterate through list of items in an object?

A
Use foreach 
        foreach( $class as $ key => $value) {
                    print "$key => $value\n";
         }
By default, all visible properties will be used for the iteration.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is overloading in php?

A

Overloading: Overloading in PHP provides means to dynamically “create” properties and methods. These dynamic entities are processed via magic methods one can establish in a class for various action types.

The overloading methods are invoked when interacting with properties or methods that have not been declared or are not visible in the current scope. The rest of this section will use the terms “inaccessible properties” and “inaccessible methods” to refer to this combination of declaration and visibility.

All overloading methods must be defined as public.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you return a reference from a function?

A

To return a reference from a function, use the reference operator & in both the function declaration and when assigning the returned value to a variable:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the use of the keyword “self” ?

A

It is used as means of class referencing its static properties

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What method is used to get defined classes ?

A
Use  get_declared_class();
Which returns an array of declared class names in current script.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly