Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> class::const, Definiowanie stałej w klasie
ennics
post
Post #1





Grupa: Zarejestrowani
Postów: 312
Pomógł: 0
Dołączył: 29.12.2004

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


cześć, mam problem ze zdefinowaniem stałej w klasie (PHP5.0.1):

  1. <?php
  2.  
  3. if (PHP_OS == 'Linux') {
  4.     $dirname = dirname(__FILE__) . DIRECTORY_SEPARATOR;
  5. } else {
  6.     $dirname = str_replace("", "/", dirname(__FILE__) . DIRECTORY_SEPARATOR);
  7. }
  8.  
  9. define('SRCDIR', $dirname);
  10. define('LIBDIR', SRCDIR . 'LIB/');
  11.  
  12. class conf {
  13.     const SOMEDIR = SRCDIR . 'd';
  14.     const SOMECNS = SRCDIR;
  15. }
  16. print conf::SOMEDIR;
  17. print conf::SOMECNS;
  18.  
  19. ?>

w rezultacie print conf::SOMEDIR daje:
Parse error: parse error, unexpected '.', expecting ',' or ';' in /var/www/test/5/2.0/conf.inc.php on line 42
print conf::SOMECNS działa dobrze:
zwraca /var/www/test/5/2.0/
dlaczego nie mogę nic dowiązać do stałej za pomocą operatora kropki ?

Ten post edytował ennics 24.11.2005, 10:25:57


--------------------
Go to the top of the page
+Quote Post

Posty w temacie
- ennics   class::const   24.11.2005, 10:24:40
- - czachor   Bo to jest stała   24.11.2005, 10:26:25
- - ennics   hmm no ok , ale wcześniej wykonałem podobną operac...   24.11.2005, 10:28:00
- - nospor   moze dlatego: Cytat"The value must be a const...   24.11.2005, 10:29:11


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: 22.08.2025 - 11:03