Q:
PHP program to create a constant using define() function
belongs to collection: PHP Classes & Objects Programs
PHP Classes & Objects Programs
- PHP program to create an object of a class and access the class attributes
- PHP program to create multiple objects of a class and access attributes of the class
- PHP program to define methods within the class
- PHP program to initialize data members without using the constructor
- PHP program to print the size of the empty class
- PHP program to create a class with setter and getter functions
- PHP program to create a class to add two distances
- PHP program to create a class to subtract one distance from another distance
- PHP program to create a class to add two times
- PHP program to convert seconds into hours, minutes, and seconds
- PHP program to convert hours, minutes, and seconds into several seconds
- PHP program to implement a cascaded function call
- PHP program to create a constant using define() function
- PHP program to create a case in-sensitive constant using define() function
- PHP program to check a constant is defined or not
- PHP program to print the line number using __LINE__ magic constant
- PHP program to print the full path of the current program file
- PHP program to print the function name using magic constant __FUNCTION__
- PHP program to print the class name using magic constant __CLASS__
- PHP program to print the method name with the associated class name using magic constant __METHOD__
- PHP program to demonstrate the use of printf() function
- PHP program to demonstrate the use of the local and global variables
- PHP program to demonstrate the default or no-argument constructor
- PHP program to implement the default or no-argument constructor using __construct()
- PHP program to demonstrate the parameterized constructor
- PHP program to implement the parameterized constructor using __construct()
- PHP program to demonstrate the use of destructor
- PHP program to demonstrate the call by value parameter passing
- PHP program to demonstrate the use of default arguments
- PHP program to demonstrate the use of variable arguments
- PHP program to demonstrate the single inheritance
- PHP program to call a base class constructor from the derived class
- PHP program to call base class destructor from the derived class
- PHP program to demonstrate the multi-level inheritance
- PHP program to demonstrate the hierarchical or tree inheritance
- PHP program to demonstrate the example of a simple interface
- PHP program to implement an interface into multiple classes
- PHP program to implement multiple interfaces in the same class
- PHP program to implement multiple-inheritance using the interface
- PHP program to demonstrate the inheritance of interfaces
- PHP program to demonstrate the example of the simple abstract class
- PHP program to inherit an abstract class into multiple non-abstract classes
- PHP program to inherit an abstract class and an interface in a non-abstract class
- PHP program to demonstrate the inheritance of abstract classes
- PHP program to demonstrate the method overriding
- PHP program to demonstrate the final keyword
- PHP program to demonstrate the method overloading based on the number of arguments
- PHP programs to pass an object of class as an argument
- PHP programs to demonstrate the function returning object
Program/Source Code:
The source code to create a constant using the define() function is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created a constant PI using the define() function that contains value 3.14. Then we created a local variable $radius initialized with 5. Then calculate the area of the circle and print the result on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer