Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Dynamiczna nazwa funkcji
matisq
post
Post #1





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 2.06.2008

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


Czy istnieje jakikolwiek sposób na utworzenie funkcji (wewnątrz klasy) z nazwą podaną jako zmienna? Wiem ze wprost raczej nei ma takiej możliwości ale może są jakieś boczne ścieżki (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
  1. <?php
  2. class Example{
  3.  
  4. var $name;
  5.  
  6. function input($name){
  7. $this->name = (string)$name;
  8. }
  9.  
  10. function $this->name(){
  11. echo "Lorem Ipsum";
  12. }
  13.  
  14. }
  15.  
  16. $name = "John";
  17.  
  18. $obj = new Example();
  19. $obj->input($name);
  20. $obj->$name();
  21.  
  22. ?>

Zdaje mi się że popełniam tu ciężką herezję ale wolę spytać (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Zatem proszę o wyrozumiałość (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Ten post edytował matisq 4.07.2008, 13:54:12
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: 22.08.2025 - 17:17