Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Probelm z własnym systemem szablonów/templet'ek
ZeTu
post
Post #1





Grupa: Zarejestrowani
Postów: 217
Pomógł: 8
Dołączył: 8.12.2010

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


Witam, nie wiem czemu ale gdy chcę wyświetlić plik x.php w index.php to wyświetla mi "1" :/ zamiast zawartości pliku.
Plik x.php
  1. jakis teskt i kod

Plik index.php
  1. $r = file_get_contents("home.php");
  2. $m2 = include 'x.php';
  3. $r = str_replace("<--asd-->", $m2, $r);
  4.  
  5. echo($r);

Plik home.php
  1. Jakis tekst i kod w srodku <--asd--> jakis kod i tekst

Jeśli w x.php będę miał tak:
  1. <?php return("jakis teskt"); ?>

To będzie działać, ale ja tak nie chcę ponieważ w pliku x.php będzie znajdować się kod php i html.
Nie da się jakoś zastąpić tego return i żeby zamiast wpisywania kodu w return, w pliku index.php po prostu wyświetlało mi tak jak powinno?

Ten post edytował ZeTu 24.09.2012, 15:58:01
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kyku
post
Post #2





Grupa: Zarejestrowani
Postów: 116
Pomógł: 8
Dołączył: 21.11.2008

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


nie możesz użyć instrukcji przypisania (znaku =) do include, który dołącza jakiś inny skrypt (no chyba, ze uzywasz tam return ale i tak dziwne rozwiazanie)
Cytat
(Handling Returns: include returns FALSE on failure and raises a warning. Successful includes, unless overridden by the included file, return 1. It is possible to execute a return statement inside an included file in order to terminate processing in that file and return to the script which called it. Also, it's possible to return values from included files. You can take the value of the include call as you would for a normal function. This is not, however, possible when including remote files unless the output of the remote file has valid PHP start and end tags (as with any local file). You can declare the needed variables within those tags and they will be introduced at whichever point the file was included.)

po prostu:
include łączy ze sobą jakieś skrypty
file_get_contents pobiera zawartość pliku (to możesz do zmiennej przypisać)

Zapoznaj się dokładniej z include i file_get_contents

Ten post edytował kyku 24.09.2012, 14:10:32
Go to the top of the page
+Quote Post

Posty w temacie
- ZeTu   [PHP] Probelm z własnym systemem szablonów/templet'ek   23.09.2012, 21:02:17
- - Yorki   Funkcja include nie zwraca zawartości pliku   23.09.2012, 21:10:53
|- - Spawnm   Cytat(Yorki @ 23.09.2012, 22:10:53 ) ...   24.09.2012, 12:38:39
- - ZeTu   Wiem, chcę tylko żeby po wyświetleniu zawartości z...   23.09.2012, 21:13:02
- - timon27   [PHP] pobierz, plaintext $r = file_get_contents...   23.09.2012, 21:32:17
- - ZeTu   No fajnie, a co jeśli mam więcej niż jedne <--a...   23.09.2012, 21:36:39
|- - timon27   Cytat(ZeTu @ 23.09.2012, 22:36:39 ) N...   23.09.2012, 22:04:08
- - Szymciosek   strlen ?   23.09.2012, 22:06:01
- - ZeTu   Timon27 to coś w ogóle nie działa :/   23.09.2012, 22:30:25
- - kyku   return nie służy do wyświetlania tekstu index.php...   23.09.2012, 22:39:28
- - ZeTu   Kyku toś teraz dowalił ... Nie o to mi chodzi   24.09.2012, 06:25:59
- - Uriziel01   Jeżeli dobrze rozumiem, w stringu masz wielokrotni...   24.09.2012, 07:15:55
- - ZeTu   Bravo Uriziel01 Jedyny mądry który zrozumiał o co...   24.09.2012, 12:20:36
- - redeemer   Bierzesz się za CMS nie znając podstaw. Skorzystaj...   24.09.2012, 12:27:16
- - ZeTu   Wiem, że istnieje Smarty, ale ja nie chcę tego uży...   24.09.2012, 12:32:39
- - redeemer   Pisałeś, że szukałeś w necie, ale żaden nie działa...   24.09.2012, 12:37:11
- - ZeTu   To co zna ktoś odpowiedź na moje pytanie (problem)...   24.09.2012, 13:17:02
- - kyku   eval   24.09.2012, 13:25:20
- - ZeTu   Próbowałem w eval i też nie działa :/   24.09.2012, 13:31:46
- - kyku   A jednak: Najprostszy przykład: index.php [PHP] p...   24.09.2012, 13:37:49
- - Spawnm   Kyku - jesteś w stanie sensownie wyjaśnić po kij t...   24.09.2012, 13:40:13
- - kyku   Spawnm, on chce w templatkach mieć kod PHP i HTML....   24.09.2012, 13:42:50
- - ZeTu   Kyku tak jak napisałeś działa, ale jak w pliku ind...   24.09.2012, 14:00:43
- - kyku   nie możesz użyć instrukcji przypisania (znaku =) d...   24.09.2012, 14:06:02
- - ZeTu   Ok, już sobie poradziłem dzięki za pomoc kyku, zro...   24.09.2012, 15:04:17
- - Uriziel01   Banał. Proszę bardzo, prosty przyklad [PHP] pobi...   25.09.2012, 08:00:59
- - lukaskolista   @kyku: z tym eval() to troszke Cie ponioslo Nigdy...   25.09.2012, 08:32:11


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: 11.10.2025 - 06:47