<?php
error_reporting(-1);
mb_internal_encoding("UTF-8");
 
$text = "А роза упала на лапу Азора";
$result = "Палиндром";
 
$text = str_replace(" ","", $text);
$text = mb_strtolower($text);

$lenght = mb_strlen($text);
$halfLenght = floor($lenght / 2);

for ($i = 0; $i <= $halfLenght; $i++) {
    $first = mb_substr ($text, 0, 1);
	$last = mb_substr ($text, -1);
	if ($first != $last) 
	{
		$result = "Не палиндром";
		break;
	}
	$text = mb_substr ($text, 1);
	$text = mb_substr ($text, 0, -1);
}
echo "Результат: {$result}";