Nice task!
I've used this ASCII table:

and this is my code:
<?php
$args = explode(" ", readline());
$word1 = $args[0];
$word2 = $args[1];
$min = min(strlen($word1), strlen($word2));
$sum = 0;
for ($i = 0; $i < $min; $i++) {
$code1 = ord($word1[$i]);//$word1: ASCII codes of the letters
$code2 = ord($word2[$i]);//$word2: ASCII codes of the letters
$sum += $code1 * $code2;
}
$remaining = '';
if (strlen($word2) > strlen($word1)) {
$remaining = substr($word2, $min);
} else {
$remaining = substr($word1, $min);
}
for ($i = 0; $i < strlen($remaining); $i++) {
$code3 = ord($remaining[$i]);
$sum += $code3;
}
echo $sum;