You can use goto to hide large HTML blocks without using echo():
<html><body>
<?php if ($hide_form_and_script) { goto label_1;} ?>
<form action="" method="post">
<!-- some HTML here -->
</form>
<script>
let a='test'; // no need to escape nested quotes as with echo()
// some JavaScript here
</script>
<?php label_1: ?>
</body></html>