Check if the password contains only numbers in PHP

Description

The following code shows how to check if the password contains only numbers.

Example


<?php// ww w .ja va 2  s .  co  m
   $password = "331231212345";
   if (strspn($password, "1234567890") == strlen($password))
      echo "The password cannot consist solely of numbers!";
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone