The available default version of php on Rocky Linux <del>CentOS</del> repository is outdated.
step.1. install the repository
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
step.2. configure modules
dnf module list php
dnf module reset php
dnf module enable php:remi-8.0
dnf module install php
step.3. install it
dnf install php
step.4. and check it
php -v