<?php
 
error_reporting(-1);
mb_internal_encoding('utf-8');
 
$text = "+7(812)678-67-67";
$q = "!^((\ ?\+?7?)|(\ ?8))!";
$w = "!(\D)!";
 
$text2 = preg_replace("$q", "8", $text);
$text3 = preg_replace("$w", "", $text2);

echo "Введено некорректный номер *$text* исправлено на *$text3*";

?>