Reference

$page->hasChildren()

Checks if the model has any children

$page->hasChildren(): bool

Return type

bool

Example

<?php
echo $page->hasChildren(); //returns the number of children in the folder

if($page->hasChildren()) {
  $children = $page->children();
}
?>

Source code

kirby/src/Cms/HasChildren.php#L153