Your count
function is not closed correctly and instead of last 'checked'
hardcoded value use $checked
variable, try this:
<input type="checkbox" name="chckbox" value="ok" class="checkbox" <?= isset($_POST['chckbox']) ? 'checked' : (count($_POST)) > 0 ? '' : $checked ?> />