I know that to show a welcome message, show an error or alert popup JavaScript is needed but is possible to use PHP instead of JavaScript to show welcome message of popup some text? Sorry just started learning PHP code and I need help with this

if (here goes PHP conditional) {
echo "<script>alert('Correct.');</script>";
} else {
echo "<script>alert('Wrong.');</script>";
}
if //something
{
error("this is an error message");
}