Accessing Digits of a Number in PHP

Attempting to get a character of a number will cause an error:

php<?php
  $num = 12345;
  echo $num[0]; // will cause an error
?>

To solve the problem, you can convert our number to a string:

php<?php
  $num = 12345;
  $str = (string) $num;
  
  echo $str[0]; // will output '1'
?>
Задание 1

Given the number 12345. Find the sum of the digits of this number.

Задание 2

Given the number 12345. Find the product of the digits of this number.

Задание 3

Given the number 12345. Rearrange the digits of this number in reverse order.