Possible Issues When Working with Sessions in PHP

The main issue when working with sessions is the following: no output can be sent to the browser before finishing work with sessions, otherwise you will see the following error: Warning: Cannot send session cookie - headers already sent.

What is output to the browser? It is any character before <?php, for example, text or a tag, even a space, as well as an error message from PHP. Furthermore, you cannot make output via echo, var_dump and print_r.

Your document's encoding must necessarily be utf-8 without BOM. If it is just utf-8, then a special character specific to this encoding will be inserted before <?php and the sessions will not work.

Задание 1

Fix the errors in the following code:

htmltext
<?php
  session_start();
?>
Задание 2

Fix the errors in the following code:

html<p>
  <?php
    session_start();
  ?>
</p>
Задание 3

Fix the errors in the following code:

html<?php
  echo 'text';
  session_start();
?>