Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> funkcja include i require
RedDoom
post
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 12.06.2010

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


Mam problem z tymi funkcjami.

Mam plik 'Draw.inc'
  1. <?php
  2. class Location {
  3. public $Left;
  4. public $Top;
  5. public function __construct() {
  6. $this->Top=0;
  7. $this->Left=0;
  8. }
  9. ?>


Nastepny plik 'control.inc'
  1. <?php
  2. include ('Draw.inc')
  3. class Draw {
  4. public $Location;
  5. public function __construct() {
  6. $this->Location=new Location;
  7. }
  8. ?>


i plik ktory uruchamiam 'test.php'
  1. <?PHP
  2. include('control.inc')
  3. $D=new Draw;
  4. $D->Location->Top=5;
  5. ?>

i otrzymuje taki komunikat
Fatal error: Class 'Location' not found in control.inc on line ...
czy ktos mi moze wytlumaczyc co robie zle
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




pliki *.inc nie są parsowane przez php. Takze ty sobie includujesz plik z klasą, ale on nie jest sparsowany przez php wiec klasa nie istnieje (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

Posty w temacie


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: 25.09.2025 - 01:48