What are the differences between using noscript and JavaScript for displaying messages in PHP?

When displaying messages in PHP, using JavaScript allows for dynamic and interactive messages to be shown to the user without requiring a page refresh. On the other hand, using noscript tags allows for messages to be displayed when JavaScript is disabled in the user's browser, ensuring that all users can still see important messages.

<?php
// Using JavaScript to display messages
echo '<script>alert("This is a message!");</script>';

// Using noscript tags to display messages
echo '<noscript>This is a message for users with JavaScript disabled.</noscript>';
?>