Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Deprecated: Function ereg() is deprecated, problem po aktualizacji php5
sebastian403
post
Post #1





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 29.11.2007

Ostrzeżenie: (0%)
-----


Witam mam jeden problem który po aktualizacji mojego php5 się uaktywnił, mianowicie.

Deprecated: Function ereg() is deprecated in /home/***/inc/functions.php on line 24

funkcja z 24 linii wygląda tak:

if(ereg("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$EmailAddress)) return true;

Może ktoś podpowiedzieć co muszę zmienić żeby uniknąć tego błędu?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 12)
kapslokk
post
Post #2





Grupa: Zarejestrowani
Postów: 965
Pomógł: 285
Dołączył: 19.06.2015
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


http://tech.cynarski.pl/2010/03/21/ereg-is...-migracja-kodu/
Go to the top of the page
+Quote Post
com
post
Post #3





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

Ostrzeżenie: (0%)
-----


zamień to na
http://php.net/manual/en/function.preg-match.php
Go to the top of the page
+Quote Post
sebastian403
post
Post #4





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 29.11.2007

Ostrzeżenie: (0%)
-----


Całą linijkę:

if(ereg("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$EmailAddress)) return true;

zamienić na:
int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )

Dobrze rozumiem?

Przepraszam, ale nie jestem tak obeznany w php czy ktoś mógłby zamienić tą linijkę kodu przystosowaną do php5 5.3?

Ten post edytował sebastian403 11.03.2016, 20:02:22
Go to the top of the page
+Quote Post
com
post
Post #5





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

Ostrzeżenie: (0%)
-----


zerknij na link kapslokk tam jest to wytłumaczone (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
sebastian403
post
Post #6





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 29.11.2007

Ostrzeżenie: (0%)
-----


tak widzę, ale dla osoby która ma tyle wspólnego z php co nic jest to czarna magia (IMG:style_emoticons/default/smile.gif)

poratuję ktoś?
Go to the top of the page
+Quote Post
rad11
post
Post #7





Grupa: Zarejestrowani
Postów: 1 270
Pomógł: 184
Dołączył: 7.10.2012
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


To co napisałeś jest parametrami jakie przyjmuje funkcja Ty musisz zrobić mniej więcej tak(nie daje sobie ręki urwać):

  1. $pattern = '/^[^@ ]+@([a-zA-Z0-9/\-]+/\.)+([a-zA-Z0-9/\-]{2}|net|com|gov|mil|org|edu|int)/\$';
  2.  
  3. preg_match($pattern, $EmailAddress, $matches);
  4.  


I w warunku sprawdzać co Ci zwróci $matches

Ten post edytował rad11 13.03.2016, 21:57:36
Go to the top of the page
+Quote Post
sebastian403
post
Post #8





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 29.11.2007

Ostrzeżenie: (0%)
-----


niestety nie działa.
Go to the top of the page
+Quote Post
com
post
Post #9





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

Ostrzeżenie: (0%)
-----


pokaż swój kod (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
viking
post
Post #10





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Czy ta funkcja ma tylko sprawdzać email? Bo domen jest już trochę więcej niż te wymienione: https://www.ovh.pl/domeny/cennik-domen/

Możesz użyć coś z tego
http://lmgtfy.com/?q=email+validator+php+github
Go to the top of the page
+Quote Post
sebastian403
post
Post #11





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 29.11.2007

Ostrzeżenie: (0%)
-----


  1. function isAddressValid($EmailAddress)
  2. {
  3. if(ereg("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$EmailAddress)) return true;
  4. else return false;
  5. }


tak tylko sprawdzać

Ten post edytował sebastian403 14.03.2016, 08:37:00
Go to the top of the page
+Quote Post
com
post
Post #12





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

Ostrzeżenie: (0%)
-----


kod po zmianach, ale lepiej myślę skorzystać z tego co podał viking
Go to the top of the page
+Quote Post
sebastian403
post
Post #13





Grupa: Zarejestrowani
Postów: 9
Pomógł: 0
Dołączył: 29.11.2007

Ostrzeżenie: (0%)
-----


Panowie mimo dużych chęci naprawdę nie znam się totalnie na tym, moje umiejętności kończą się na kopiuj wklej.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 14:50