Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem z zmienną PHP
Forum PHP.pl > Forum > PHP > Object-oriented programming
alkesz1718
Witam, od jakiegoś czasu pracuję nad pewnym projektem strony muzycznej gdzie player dodawany jest z bbcode np:
  1. [hl=http://hu.lk/m1sq63fee6f4]


w swoim oprogramowaniu strony gdzie ten tag zmienia na player mam coś takiego:

  1. /* Hulkshare Player */
  2. function build_hulk( $matches=array() ) {
  3. global $config;
  4. $hurl = $matches[1];
  5.  
  6. if( $hurl == "" ) return;
  7. if( preg_match( "/[?&;%<\[\]]/", $hurl ) ) {
  8. return "[hl=" . $hurl . "]";
  9. }
  10. $hurl = $this->clear_url( $hurl );
  11. return "
  12.  
  13. <iframe id=\"hulkshare-player-embed\" name=\"hulkshare-player-embed\"
  14. src=\"http://www.hulkshare.com/hsPlayer/embed/embed_clean.php?fn=$hulk
  15. &enableDownload=0&enableCover=0&enableAdd=false&bg=undefined&fg=undefined&iconColor=undefined&backColor=undefined&outColor=undefined&overColor=undefined&
  16. textColor=undefined&tintColor=undefined&pid=&type=7&width=100%\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"width:100%;height:160px;\">
  17. </iframe>
  18. ";}
  19. /* End HulkShare Player */


Gdzie
  1. $hurl
to jest to co jest dodawane w tagu bbcode

Teraz chcę zrobić coś takiego:



Czyli chcę w tym moim kodzie z linku wyciągnąć tą część która jest potrzebna do kodu Iframe (w inny sposób nie zadziała player)

Byłbym bardzo wdzięczny gdyby ktoś do tego kodu dopisał zmienną na to. Ja niestety zaczynam prace z PHP i nie do końca umiem te wszyskie zmienne tworzyć
markuz
  1. $url = 'http://hu.lk/er40pctcmyv4';
  2. $id = end(explode('/', $url));
alkesz1718
Chyba nie do końca ja rozumiem o co w tym chodzi...

ja chcę by do tego kodu:
  1. /* Hulkshare Player */
  2. function build_hulk( $matches=array() ) {
  3. global $config;
  4. $hurl = $matches[1];
  5.  
  6. if( $hurl == "" ) return;
  7. if( preg_match( "/[?&;%<\[\]]/", $hurl ) ) {
  8. return "[hl=" . $hurl . "]";
  9. }
  10. $hurl = $this->clear_url( $hurl );
  11. return "
  12.  
  13. <iframe id=\"hulkshare-player-embed\" name=\"hulkshare-player-embed\"
  14. src=\"http://www.hulkshare.com/hsPlayer/embed/embed_clean.php?fn=$hulk
  15. &enableDownload=0&enableCover=0&enableAdd=false&bg=undefined&fg=undefined&iconColor=undefined&backColor=undefined&outColor=undefined&overColor=undefined&
  16. textColor=undefined&tintColor=undefined&pid=&type=7&width=100%\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"width:100%;height:160px;\">
  17. </iframe>
  18. ";}
  19. /* End HulkShare Player */
  20.  
  21.  


Dopisać w odpowiednim miejscu zmienną która ma takie działanie jak podałem na obrazku
markuz
Podałem rozwiązanie twojego problemu. Pogłówkuj trochę w przeciwnym wypadku zapraszam do tego działu. smile.gif
alkesz1718
  1. /* Hulkshare Player */
  2. function build_hulk( $matches=array() ) {
  3. global $config;
  4.  
  5. $hurl = $matches[1];
  6. if( $hurl == "" ) return;
  7. if( preg_match( "/[?&;%<\[\]]/", $hurl ) ) {
  8. return "[hl=" . $hurl . "]";
  9. }
  10. $hurl = $this->clear_url( $hurl );
  11. $hulk = end(explode('/', $hurl));
  12.  
  13. return "
  14.  
  15. <iframe id=\"hulkshare-player-embed\" name=\"hulkshare-player-embed\"
  16. src=\"http://www.hulkshare.com/hsPlayer/embed/embed_clean.php?fn=$hulk
  17. &enableDownload=0&enableCover=0&enableAdd=false&bg=undefined&fg=undefined&iconColor=undefined&backColor=undefined&outColor=undefined&overColor=undefined&
  18. textColor=undefined&tintColor=undefined&pid=&type=7&width=100%\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"width:100%;height:160px;\">
  19. </iframe>
  20. ";}
  21. /* End HulkShare Player */


Powiedzmy że działa ale ta zmienna od ciebie powoduje mi błąd w skrypcie podczas edytowania artykułu:
Strict Standards: Only variables should be passed by reference in /usr/home/user/domains/site.pl/public_html/engine/classes/parse.class.php on line 1222
Strict Standards: Only variables should be passed by reference in /usr/home/user/domains/site.pl/public_html/engine/classes/parse.class.php on line 1222


ale z tym chyba się już udam do supportu silnika może będą wiedzieć w czym tkwi błąd
daniel1302
Błąd jest w twojej funkcji, próbujesz przekazać przez referencje coś co nie jest zmienną np wynik prosto z funkcji.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.