<?php
//64160267 Kanokpol Promtha
// Caesar
function exam03($s,$text)
{
$result = "";
//text
for ($i = 0; $i < strlen($text); $i++)
{
// transformation to each
if (ctype_upper($text[$i]))
$result = $result.chr((ord($text[$i]) +
$s - 65) % 26 + 65);
else
$result = $result.chr((ord($text[$i]) +
$s - 97) % 26 + 97);
}
// Return the resulting string
return $result;
}
function test_01(){
if(exam03(3, "ABC") == "DEF"){
echo "pass";
} else {
echo "fail";
}
if(exam03(3, "ZXY") == "CAB"){
echo "pass";
} else {
echo "fail";
}
}
test_01();