Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. <?php
  2.  
  3. function verifierLogin($login)
  4. {
  5.     if (strlen($login) < 4) {
  6.         throw new InvalidArgumentException("Votre login doit contenir au moins 4 caractères");
  7.     }
  8.    
  9.     if (strlen($login) > 10) {
  10.         throw new InvalidArgumentException("Votre login ne doit pas dépasser les 10 caractères");
  11.     }
  12. }
  13.  
  14. function verifierFormulaire(array $form)
  15. {
  16.     try {
  17.         verifierLogin($form);
  18.     } catch (InvalidArgumentException $exception) {
  19.         echo "<span class='error'>" . $exception->getMessage() . "</span>";
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement