Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php5] wszystko jest obiektem
Apo
post
Post #1





Grupa: Zarejestrowani
Postów: 426
Pomógł: 1
Dołączył: 2.10.2005

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


nudziło mi sie i postanowiłem napisać coś dziwnego (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

  1. <?php
  2.  
  3. class Box {
  4.  
  5. private $box;
  6.  
  7. public function __construct($value = null)
  8. {
  9. if(!is_null($value))
  10. $this->box = $value;
  11. }
  12.  
  13. public function __call($method, $args)
  14. {
  15. if($this->box)
  16.  array_unshift($args, $this->box);
  17.  
  18. return call_user_func_array($method, $args);
  19. }
  20.  
  21. }
  22.  
  23. $ciag = new Box('ciag');
  24. echo $ciag->substr(0, 2); // zwroci "ci"
  25. echo $ciag->strtoupper(); // zwroci "CIAG"
  26.  
  27. $box = new Box;
  28. echo $box->strlen('cos dlugiego'); // zwroci 12
  29.  
  30. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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: 29.09.2025 - 06:51