0

i'm new to php i tried to check if age is valid or not, i used the ereg function it displays the result fine but there is an error Deprecated: Function ereg () is deprecated in D:\wamp\www\functions\index.php on line 5, I don't know how to fix it. I tried preg_match instead of ereg but it doesn't work it gives me error preg_match (): Unknown modify '?'

<?php

 $modele = "^[0-9]?([0-9]?)$";
 $age = "848";
 if(preg_match($modele,$age)){
    echo "age is valide <br>";
    return true;
 }else{
    echo "age is invalide <br>";
    return false;
 }
  ?>
achraf bourki
  • 33
  • 1
  • 7

0 Answers0