Normal Position flags in Yii 2.0's View

In Yii 2.0's View, we have 5 flags for position, it's beginPage, head(), beginBody(), endBody(), endPage(). This topic show how to use it correct in view file, if not use it correct, may cost js or css file or code can't register correct

{ Demo }

<?php $this->beginPage()?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">

....

<head>
    <meta charset="<?= Yii::$app->charset ?>">

...

    <?= Html::csrfMetaTags()?>
    <title><?= Html::encode($this->title) ?></title>
    
    <?php $this->head()?>

</head>
<body>
<?php $this->beginBody()?>

...

<?php $this->endBody()?>
</body>
</html>
<?php $this->endPage()?>