What is the difference between defining constants with "const" and "define" in PHP?

In PHP, defining constants with "const" is used within classes to create class constants, while defining constants with "define" is used outside of classes to create global constants. "const" is a language construct, while "define" is a function. Using "const" provides better scoping and encapsulation, as class constants are only accessible within the class, while global constants defined with "define" are accessible throughout the script.

// Using const to define a class constant
class MyClass {
    const MY_CONSTANT = 'Hello';
}

// Using define to define a global constant
define('GLOBAL_CONSTANT', 'World');