3v4l.org

run code in 300+ PHP versions simultaneously
<?php function validatePhone( $phone, &$errsData = null, &$mainData = null ) { $res = false; if( isset( $phone ) && $phone != null ) { $phone = preg_replace("/[^0-9]/","", $phone ); //удаляем всё кроме цифр if ($phone && preg_match('/^(8|7|\+7)[0-9]{10}$/', $phone )) { // if( substr( $phone, 0, 1) == '8' ) $phone[0] = '7'; @$mainData['phone'] = $phone; $res = $phone; } else { $errsData['phone']['error_msg'] = "Укажите номер в формате +7 000 000 00 00"; } } else { $errsData['phone']['error_msg'] = "Укажите Ваш номер телефона"; } return $res; } var_dump ( validatePhone('+79278918933') ); ?>
Output for git.master, git.master_jit, rfc.property-hooks
string(11) "79278918933"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
32.41 ms | 401 KiB | 8 Q