Which is better #define or enum?



Which is better #define or enum?..

Answer / Rajat Kumar Srivastav

#define is a preprocessor directive in C/C++ that replaces the token with a specific text during the compilation process. It is useful for creating constants or macros. On the other hand, enums are a type-safe enumeration in C/C++ and PHP. Enums allow you to create named integer values, which can be more readable and safer than using #define. In PHP, enums were introduced in version 8.1.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

Explain how can php and javascript interact?

1 Answers  


What is the difference between $name and $$name?

1 Answers  


How many types of array are there in php?

1 Answers  


How can we change the value of a constant?

1 Answers  


how to install openssl, ISAPI, pdf modules in php 5.2.5 with apache on windows xp.

2 Answers  


What is the difference between file_get_contents() and file_put_contents() in php?

1 Answers  


What is the php function that removes the last element of the array and returns it?

1 Answers  


Explain about PHP cookies?

1 Answers  


Explain the difference between $var and $$var?

1 Answers  


Tell me how comfortable are you with writing html entirely by hand?

1 Answers  


Is empty array php?

1 Answers  


What is in a cookie?

1 Answers  


Categories