How can the use of undefined constants in PHP code impact the functionality of a script, and how can this issue be resolved?

Using undefined constants in PHP code can lead to errors or unexpected behavior in a script. To resolve this issue, you should define the constants before using them in your code. This can be done using the define() function in PHP.

// Define the constant before using it
define('MY_CONSTANT', 'Hello World');

// Now you can use the constant in your code
echo MY_CONSTANT;