How can the "checked" attribute be properly implemented in checkbox inputs in PHP forms to ensure correct functionality?

When using checkbox inputs in PHP forms, the "checked" attribute should be added to the input tag if the checkbox is selected. This can be achieved by checking if the checkbox value is present in the form submission data. If the checkbox value is present, the "checked" attribute should be added to the input tag to ensure correct functionality.

<input type="checkbox" name="checkbox_name" value="1" <?php if(isset($_POST['checkbox_name'])) echo 'checked'; ?>>