Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Czy ta klasa jest dobra?
alex011251
post
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 (IMG:style_emoticons/default/tongue.gif) P Bo ucze sie dopiero

Ten post edytował alex011251 25.05.2013, 17:39:28
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
alex011251
post
Post #2





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

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


czyli
construktor
jakas metoda - z curlem
i sprawdzanie w kolejnej metodzie czy jest czy nie ma.


?

OOP myslalem ze bedzie latwiejsze. A dluga droga przedemna

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: 7.10.2025 - 19:43