首页 > 解决方案 > echo alert() in php show everything in the string. octobercms plugin

问题描述

I'm having issue when echoing alert() in php. It show everything in the string.

echo "<script type='text/javascript'>alert('Thank you for your enquiry, we will contact you as soon as possible, have a nice day!');</script>";

Output

标签: javascriptphppluginsoctobercms

解决方案


You can use javascript code between ending and starting php tags like below,

    ?>
<script type="text/javascript">
alert('Thank you for your enquiry, we will contact you as soon as possible, have a nice day!');
</script>
<?php
// rest of the php code will go here.
?>

OR try this please,

<?php
echo '<script type="text/javascript">';
echo 'alert("Thank you for your enquiry, we will contact you as soon as possible, have a nice day!");';
echo '</script>';
?>


推荐阅读