Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php] błąd array_key_exists()
Forum PHP.pl > Forum > PHP
Lejto
Mam klase User a w niej
  1. <?
  2. class User
  3. {
  4. private $uid;
  5. private $fields;
  6.  
  7. public function __construct($sql)
  8. {
  9. $this->sql = $sql;
  10. $this->uid = null;
  11. $this->fields = array('username' => '',
  12. 'password' => '',
  13. 'emailAddr' => '',
  14. 'isActive' => false);
  15.  
  16. }
  17. public function __get($field)
  18. {
  19. if($field == 'userId')
  20. {
  21. return $this->uid;
  22. }
  23. else
  24. {
  25. return $this->fields[$field];
  26. }
  27. }
  28. public function __set($field, $value)
  29. {
  30. if(array_key_exists($field, $this->fields))
  31. {
  32. $this->fields[$field] = $value;
  33. }
  34. }
  35. //dalej


dostaje taki błąd
Kod
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in J:\Serv\www\1B\libs\user.class.php on line 33


Co jest nie tak?

Pozdrawiam
batman
  1. private $fields = array();
i będzie hulać.

edit
Ewentualnie:
  1. private $fields = array('username' => '',
  2. 'password' => '',
  3. 'emailAddr' => '',
  4. 'isActive' => false);
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.