I am currently looking for a way to insert JavaScript into my php code, however, I cannot do it within an echo. I am considering using the following workaround:
<?php
some code
?>
<script type="text/javascript>
js things
</script>
<?php
more code
?>
I am, however, a bit worried about opening and closing the <?php part. Is this considered bad practice and why?
Though I would warn you to be frugal when mixing different script types, this is very normal and acceptable in programming. If you can find a way around it, I would suggest it, but this is far better than attempting to echo Javascript from PHP.