Examveda

A function in PHP which starts with ______ (double underscore) is know as.

A. Magic Function

B. Inbuilt Function

C. Default Function

D. User Defined Function

Answer: Option A

Solution (By Examveda Team)

Option A: Magic Function
In PHP, a function that starts with double underscores (__) is known as a magic function.
These functions are predefined in PHP and are automatically called when certain events or operations occur.
Examples include __construct, __destruct, __get, __set, and many others, which are automatically invoked when specific conditions are met in the code.

Option B: Inbuilt Function
Inbuilt functions in PHP are built into the language and are not necessarily prefixed with double underscores.
They are regular functions like echo(), print(), and other standard PHP functions, but do not follow the magic function naming convention.

Option C: Default Function
There is no specific category called "default function" in PHP.
This term is not commonly used in the context of PHP function naming or functionality.

Option D: User Defined Function
User-defined functions are those created by the developer, and they do not follow the double underscore convention.
These functions are typically defined with a name chosen by the user and are not prefixed with any special characters like the magic functions.

Conclusion:
The correct answer is Option A: Magic Function.
Magic functions in PHP start with double underscores and are automatically invoked by PHP under certain conditions.

This Question Belongs to PHP >> Functions

Join The Discussion

Related Questions on Functions