Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> php stdClass
jarmiar
post
Post #1





Grupa: Zarejestrowani
Postów: 617
Pomógł: 12
Dołączył: 16.07.2006
Skąd: : getCity ( );

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


witam, mój problem jest nastepujacy:

  1. class Database
  2. {
  3. private $_content = NULL;
  4.  
  5. private $_action = NULL;
  6.  
  7. private $_fileName = NULL;
  8.  
  9. public function __construct ( $fileName )
  10. {
  11. if ( file_exists ( $fileName ) )
  12. {
  13. $this -> _fileName = $fileName;
  14. try
  15. {
  16. $content = file_get_contents ( $fileName );
  17. $this -> _content = json_decode ( $content );
  18. }
  19. catch ( Exception $e )
  20. {
  21. echo $e;
  22. }
  23. }
  24. else
  25. {
  26. echo 'plik nie istnieje';
  27. }
  28. }
  29. }


przez json_decode() dostaje dane w postaci obiektu stdClass w dalszej czesci mojego kodu probuje dodac nowe pozycje no i dostaje blad:

Fatal error: Cannot use object of type stdClass as array in C:\xampp\htdocs\txtdb.php on line 50

załozeniem mojego kodu jest obslugfa plikow tekstowych jak bazy danych.

prosze mi wyjasnic jak odwolac sie do stdClass object, abym mogl dodac tam nowe pozycje


Go to the top of the page
+Quote Post

Posty w temacie
- jarmiar   php stdClass   17.07.2012, 16:54:22
- - CuteOne   Następnym razem wpisz błąd w google.. json_decod...   17.07.2012, 17:48:50


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: 3.04.2026 - 20:16