Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Porty losowe
zaba12
post
Post #1





Grupa: Zarejestrowani
Postów: 223
Pomógł: 0
Dołączył: 29.08.2003
Skąd: Gliwice

Ostrzeżenie: (10%)
X----


Jak zrobic zeby skrypt losowal port od 10000 w gore co 2 ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
webdice
post
Post #2


Developer


Grupa: Moderatorzy
Postów: 3 045
Pomógł: 290
Dołączył: 20.01.2007




  1. <?php
  2.  
  3. function randPort ()
  4. {
  5. $int = rand (10000, 20000);
  6.  
  7. if ($int % 2 == 0)
  8. {
  9. return $int;
  10. }
  11. else
  12. {
  13. return randPort ();
  14. }
  15. }
  16.  
  17. print randPort ();
  18.  
  19. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 15.10.2025 - 06:30