Check,characters,,variable,are,alpha,numeric,using,ereg

Yavuz 8/31/2016 0

Check that characters in a variable are alpha numeric using ereg in php

PHP
<?php
// Example 1$text = "onlyalphanumericcharacters012345";
if (ereg('[^A-Za-z0-9]', $text)) 
{  
echo "This contains characters other than letters and numbers";}
else {  echo "This contains only letters and numbers";    }
// Example 2$text = "mixedcharacters012345&../@";
if (ereg('[^A-Za-z0-9]', $text)) 
{  echo "This contains characters other than letters and numbers";}
else {  echo "This contains only letters and numbers";    }
?>
 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments