Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Czy ta klasa jest dobra?
alex011251
post 25.05.2013, 17:27:06
Post #1





Grupa: Zarejestrowani
Postów: 40
Pomógł: 3
Dołączył: 21.05.2013

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


  1. <?php
  2. class classSecurityBasicAuth {
  3. public $zmienna = '';
  4. public function __construct($url, $komunikat) {
  5. $handle = curl_init($url);
  6. curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  7. curl_setopt($handle, CURLOPT_NOBODY, true);
  8. curl_exec($handle);
  9.  
  10. $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
  11. if ($httpCode == 200) {
  12. $this -> zmienna = '<img src="'.$url.'" />';
  13. } else {
  14. $this -> zmienna = $komunikat;
  15. }
  16. curl_close();
  17. }
  18. public function funkcja() {
  19. return $this->zmienna;
  20. }
  21. }
  22.  
  23.  
  24.  
  25.  
  26. $security = new classSecurityBasicAuth('http://c.allegrostatic.pl/images/velalayout/434de666.allegro-logo.png', '<img src= "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Nie_istnieje.svg/100px-Nie_istnieje.svg.png"/>');
  27. echo $security->funkcja();
  28. ?>



Uprzedzam. Chodzi czy dobrze konstruuje tongue.gifP Bo ucze sie dopiero

Ten post edytował alex011251 25.05.2013, 17:39:28
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 Wersja Lo-Fi Aktualny czas: 24.07.2025 - 16:36