Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> serialize a obiekt, klasy SimpleXMLElement
aleksander
post 28.12.2004, 12:35:57
Post #1





Grupa: Przyjaciele php.pl
Postów: 742
Pomógł: 0
Dołączył: 14.12.2003
Skąd: Gdańsk, Trójmiasto

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


Witam,

mam następujące kody ( do robienia pliku konfiguracyjnego w xml ):
  1. <?php
  2. class ConfigParser
  3. {
  4. private $config;
  5.  
  6. public function __construct()
  7. {
  8. $this -> loadConfig();
  9. }
  10.  
  11.  
  12. public function loadConfig()
  13. {
  14. if( filemtime( 'config.php' ) < filemtime( 'config.xml' ) )
  15. {
  16. $this -> parseConfig();
  17. } else {
  18. $this -> config = unserialize( file_get_contents( 'config.php' ) ); // linia 18
  19. }
  20.  
  21. }
  22.  
  23. public function parseConfig()
  24. {
  25. $this -> config = simplexml_load_file( 'config.xml' );
  26. file_put_contents( 'config.php', serialize( $this -> config) );
  27.  /* echo '<pre>';
  28. var_dump( $this -> configFile );
  29. echo '</pre>';  */
  30. }
  31. // Kilka metod wyciągających poszczególne dane np.:
  32. public function getPostLoadingModules( $module = false )
  33. {
  34. return $this -> config -> postloadingmodules -> module;
  35. if( $module !== false )
  36. {
  37. if( isset( $this -> config -> postLoadingModules -> module[$path] ) )
  38. {
  39. return $this -> config -> postLoadingModules -> module[$path];
  40. } else {
  41. return false;
  42. }
  43. } else {
  44. return $this -> config -> postloadingmodules -> module;
  45. }
  46. }
  47. }
  48. ?>
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <kernel-config>
  3.  <paths>
  4.    <modules-path>module/</modules-path>
  5.    <auth-path>auth/</auth-path>
  6.  </paths>
  7.  
  8.  <preloadingmodules>
  9.    <module>headery</module>
  10.    <module>menu</module>
  11.    <module>calendar</module>
  12.  </preloadingmodules>
  13.  
  14.  <postloadingmodules>
  15.    <module>stats</module>
  16.    <module>footer</module>
  17.  </postloadingmodules>
  18. </kernel-config>
Cytat("config.php")
O:16:"SimpleXMLElement":3:{s:5:"paths";O:16:"SimpleXMLElement":2:{s:12:"modules-path";s:7:"module/";s:9:"auth-path";s:5:"auth/";}s:17:"preloadingmodules";O:16:"SimpleXMLElement":1:{s:6:"module";a:3:{i:0;s:7:"headery";i:1;s:4:"menu";i:2;s:8:"calendar";}}s:18:"postloadingmodules";O:16:"SimpleXMLElement":1:{s:6:"module";a:2:{i:0;s:5:"stats";i:1;s:6:"footer";}}}

który zwraca następujące błedy:
Cytat("errory")
Warning: unserialize() [function.unserialize]: Node no longer exists in C:\www\xampp\htdocs\engine\config.parser.php on line 18
No i ja po prostu nie wiem co mam z tym zrobić sad.gif

Ten post edytował olo 28.12.2004, 12:36:40
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
hwao
post 28.12.2004, 14:06:25
Post #2


Developer


Grupa: Moderatorzy
Postów: 2 844
Pomógł: 20
Dołączył: 25.11.2003
Skąd: Olkusz




http://pl2.php.net/manual/pl/language.oop.serialization.php
Go to the top of the page
+Quote Post
aleksander
post 28.12.2004, 14:20:26
Post #3





Grupa: Przyjaciele php.pl
Postów: 742
Pomógł: 0
Dołączył: 14.12.2003
Skąd: Gdańsk, Trójmiasto

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


@hwao: zauwarz, że SimpleXMLElement jest klasą wbudowaną, nie mogę sobie jej zmieniać.
Go to the top of the page
+Quote Post
hawk
post 28.12.2004, 21:56:12
Post #4





Grupa: Zarejestrowani
Postów: 521
Pomógł: 0
Dołączył: 3.11.2003
Skąd: 3city

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


http://www.codecomments.com/PHP_XML/message150675.html
http://news.php.net/php.xml.dev/205
Serwer news.php.net chyba wziął sobie akurat wolne, więc sam musisz dojść, czemu tego nie można robić.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 18.07.2025 - 01:34