validPhone - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of validPhone.php
- <?php
- function ValidPhone($phone) {
- $valid = false;
- if (!is_string($phone)) {
- $valid = true;
- echo 'is_string true';
- }
- if (!preg_match('/((8|\+7)-?)?\(?\d{3,5}\)?-?\d{1}-?\d{1}-?\d{1}-?\d{1}-?\d{1}((-?\d{1})?-?\d{1})?/', $phone)) {
- $valid = true;
- echo 'preg_match true';
- }
- if ( strlen($phone)<=7 && strlen($phone)>=12 ) {
- $valid = true;
- echo 'strlen true';
- }
- if ( $valid ) {
- return true;
- }
- return false;
- }
- var_dump(ValidPhone('109062667234234467'));
- ?>
File Description
- validPhone
- PHP Code
- 08 Aug-2022
- 519 Bytes
You can Share it:
Latest PHP Pastes