Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Błędy Deprecated: Function ereg()
Forum PHP.pl > Forum > PHP
sylwekb
Witam, dostawca hostingu najprawdopodobniej zaktualizował wersję php i zaczęło mi krzaczyć błędami w poniższym pliku. Czy można zastąpic jakoś to polecenie z ereg?

Deprecated: Function ereg() is deprecated in ... on line 9

Deprecated: Function ereg() is deprecated in ... on line 18

Deprecated: Function ereg() is deprecated in ... on line 23

Deprecated: Function ereg() is deprecated in ... on line 39

Deprecated: Function ereg() is deprecated in ... on line 39

  1. <?
  2. if (!function_exists('check_email_address'))
  3. {
  4.  
  5. function check_email_address($email)
  6. {
  7. // First, we check that there's one @ symbol, and that the lengths are right
  8.  
  9. if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email))
  10. { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
  11. return false;
  12. }
  13. // Split it into sections to make life easier
  14. $email_array = explode("@", $email);
  15. $local_array = explode(".", $email_array[0]);
  16. for ($i = 0; $i < sizeof($local_array); $i++)
  17. {
  18. if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i]))
  19. {
  20. return false;
  21. }
  22. }
  23. if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1]))
  24. {
  25. // Check if domain is IP. If not, it should be valid domain name
  26. $domain_array = explode(".", $email_array[1]);
  27. if (sizeof($domain_array) < 2)
  28. {
  29. return false;
  30. // Not enough parts to domain
  31. }
  32.  
  33. if (strlen($domain_array[count($domain_array)-1])<2) {
  34. return false;
  35. // zbyt krótka nazwa domeny głównej
  36. }
  37. for ($i = 0; $i < sizeof($domain_array); $i++)
  38. {
  39. if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i]))
  40. {
  41. return false;
  42. }
  43. }
  44. }
  45. return true;
  46. }
  47. }
  48. ?>
markuz
  1. function check_email_address($email) {
  2. return filter_var($email, FILTER_VALIDATE_EMAIL);
  3. }
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.