Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> serialize a obiekt, klasy SimpleXMLElement
aleksander
post
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

Posty w temacie


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 Aktualny czas: 21.08.2025 - 17:01