Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]Wczytywanie pliku .php przez file_get_contents .
Kaiba Ziom
post
Post #1





Grupa: Zarejestrowani
Postów: 49
Pomógł: 0
Dołączył: 25.10.2006
Skąd: Londyn

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


  1. <?
  2.  define ("hehe", file_get_contents("test.php"));
  3.  
  4.  include("config.php");
  5.  class template
  6.  {
  7. function load_file($template, $file)
  8.  {
  9. if(!$fd = fopen("templates/$template/$file.html", 'r'))
  10. {
  11.  echo("<center><h1>Error</h1></center><br><center>Błąd w wczytywaniu skórki.</center>");
  12. }
  13. else
  14. {
  15. $rozmiar = filesize("templates/$template/$file.html");
  16. $result = fread($fd, $rozmiar);
  17. }
  18. return $result;
  19.  }
  20. function make_arg($file, $whatreplace, $result)
  21. {
  22.  $result = str_replace("<!--$whatreplace-->", $result, $file);
  23.  return $result;
  24. }
  25.  }
  26.  {
  27. $template = new template();
  28. if ($templates == 1) {
  29. $main_template = $template->load_file("1", "index");
  30. } elseif ($templates == 2) {
  31. $main_template = $template->load_file("2", "index");
  32. } elseif ($templates == 3) {
  33. $main_template = $template->load_file("error", "index");
  34. }
  35. {
  36. $test = file_get_contents('test.php');
  37. $main_template = $template -> make_arg($main_template, "login", "To jest logowanie");
  38. $main_template = $template -> make_arg($main_template, "login1", "To jest logowanie1");
  39. $main_template = $template -> make_arg($main_template, "test", hehe);
  40. }
  41.  }
  42.  echo $main_template;
  43. ?>

Mam taki plik , a w index.html mam:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2"/>
  4. <title>Nasza Tibia</title>
  5. <meta http-equiv="Content-Language" content="PL">
  6. <meta name="description" content="Rozbudowany serwis o wspaniałej grze MMorpg jaką jest Tibia.">
  7. <meta name="ROBOTS" content="index, follow">
  8. <meta name="Author" content="Mazur">
  9. <link rel="Stylesheet" type="text/css" href="./templates/1/style.css" />
  10. </head>
  11. <br />
  12. Hola Ziomy :)
  13. <p class="info">Test</p>
  14. <br>
  15. <!--test-->
  16. </body>
  17. </html>

w test.php:
  1. <?php
  2. echo 'nic';
  3. ?>

Chodzi o to że jeżeli napiszę <!--test--> to chcę mieć wartość test.php .
Lecz kiedy wchodzę w przeglądarkę to jak dam w test.php naprzykład:"test" to wyświetli się test , a jak dam
  1. <?php
  2. echo 'test';
  3. ?>

To nie ma tego (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) .
Co mogę zrobić?
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: 21.12.2025 - 11:52