Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> __autoload i set_include_path
Pax95
post
Post #1





Grupa: Zarejestrowani
Postów: 50
Pomógł: 7
Dołączył: 31.01.2009

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


Mam problem. Tworzę frameworka, ale podczas modyfikacji pliku zauważyłem błąd w przeglądarce:
Cytat
Przerwane połączenie
Połączenie z serwerem zostało zresetowane podczas wczytywania strony.
Połączenie sieciowe zostało przerwane podczas negocjacji. Spróbuj ponownie.

Znika on, gdy usunę jeden z poniższych kodów:
  1. <?php
  2. set_include_path( get_include_path().PATH_SEPARATOR.'core/' );
  3. ?>

  1. <?php
  2. function __autoload( $ClassName )
  3. {
  4.    include $ClassName. '.php';
  5. }
  6. ?>

Niekiedy udało mi się wywołać error:
Cytat
Fatal error: Cannot redeclare class init in D:\wamp\www\pframework\core\init.php on line 11
Go to the top of the page
+Quote Post
erix
post
Post #2





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Ok, od ogółu do szczegółu: na innym serwerze to samo?
Go to the top of the page
+Quote Post
Pax95
post
Post #3





Grupa: Zarejestrowani
Postów: 50
Pomógł: 7
Dołączył: 31.01.2009

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


Wgrałem na linuxpl.com i wywaliło następujące błędy:
Cytat
Warning: include(Kernel.php) [function.include]: failed to open stream: No such file or directory in /home/pax/domains/piczer.info/public_html/pframework/index.php on line 7

Warning: include(Kernel.php) [function.include]: failed to open stream: No such file or directory in /home/pax/domains/piczer.info/public_html/pframework/index.php on line 7

Warning: include() [function.include]: Failed opening 'Kernel.php' for inclusion (include_path='.:/usr/local/lib/php:core/') in /home/pax/domains/piczer.info/public_html/pframework/index.php on line 7

Fatal error: Class 'Kernel' not found in /home/pax/domains/piczer.info/public_html/pframework/index.php on line 10


index.php
  1. <?php
  2.  
  3. set_include_path( get_include_path().PATH_SEPARATOR.'core/' );
  4.  
  5. function __autoload( $ClassName )
  6. {
  7.    include $ClassName.'.php';
  8. }
  9.  
  10. $Config = Kernel::load( 'config' );
  11.  
  12. /*$Router = Kernel::load( 'router' );   ######## DEBUG
  13. $Router->init( $Config->router );*/
  14.  
  15. ?>


EDIT zauwazylem, ze pliku core/ jest kernel.php, więc poprawiłem, a teraz się wyświetla error 500.

Ten post edytował Pax95 18.07.2009, 12:13:09
Go to the top of the page
+Quote Post
erix
post
Post #4





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Chyba nie ustawiłeś include_path. [;
Go to the top of the page
+Quote Post
Pax95
post
Post #5





Grupa: Zarejestrowani
Postów: 50
Pomógł: 7
Dołączył: 31.01.2009

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


Jak nie?

  1. <?php
  2. set_include_path( get_include_path().PATH_SEPARATOR.'core/' );
  3. ?>
Go to the top of the page
+Quote Post
erix
post
Post #6





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Cytat
EDIT zauwazylem, ze pliku core/ jest kernel.php, więc poprawiłem, a teraz się wyświetla error 500.


A przy bezpośrednim podaniu ścieżki, bez set_include_path" title="Zobacz w manualu PHP" target="_manual dzieje się to samo?
Go to the top of the page
+Quote Post
Pax95
post
Post #7





Grupa: Zarejestrowani
Postów: 50
Pomógł: 7
Dołączył: 31.01.2009

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


  1. <?php
  2. //set_include_path( get_include_path().PATH_SEPARATOR.'core/' );
  3.  
  4. function __autoload( $ClassName )
  5. {
  6.    include 'core/' .$ClassName. '.php';
  7. }
  8. ?>

O to chodzi? Nadal nie działa.
Go to the top of the page
+Quote Post
erix
post
Post #8





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




A błędami sypie?
Go to the top of the page
+Quote Post
Pax95
post
Post #9





Grupa: Zarejestrowani
Postów: 50
Pomógł: 7
Dołączył: 31.01.2009

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


Nie, jest internal server error.
Go to the top of the page
+Quote Post
erix
post
Post #10





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




A spl_autoload_register" title="Zobacz w manualu PHP" target="_manual?
Go to the top of the page
+Quote Post
Pax95
post
Post #11





Grupa: Zarejestrowani
Postów: 50
Pomógł: 7
Dołączył: 31.01.2009

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


Można tak kombinować, i pewnie robimy to w złą stronę. Musi być problem gdzieś indziej, ale nie wiem jak go znaleźć. Ta funkcja działała wcześniej dopóki nie zmodyfikowałem czegoś. Pamiętam, że chciałem foldery wywalić z public_html na zewnątrz, a potem wróciłem, bo było za dużo modyfikacji kodu do zrobienia.
Go to the top of the page
+Quote Post
erix
post
Post #12





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Może pokaż po prostu strukturę całości?
Go to the top of the page
+Quote Post
Pax95
post
Post #13





Grupa: Zarejestrowani
Postów: 50
Pomógł: 7
Dołączył: 31.01.2009

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


O to chodzi?
CODE
D:\wamp\www\pframework\
| .htaccess
| index.php
|
|---app
| |
| |---config
| | | config.php
| |
| |---controllers
| |
| |---helpers
| | | validator.php
| |
| |---models
| |
| |___views
|
|___core
| config.php
| debug.php
| dispather.php
| init.php
| kernel.php
| router.php

Na stan dzisiejszy
Go to the top of the page
+Quote Post
erix
post
Post #14





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




A jakieś przykładowe wywołanie? (które wyzwala autoload)
Go to the top of the page
+Quote Post
Pax95
post
Post #15





Grupa: Zarejestrowani
Postów: 50
Pomógł: 7
Dołączył: 31.01.2009

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


? Nie rozumiem
Go to the top of the page
+Quote Post
erix
post
Post #16





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




No, kawałek pliku, który wyzwala autoload.
Go to the top of the page
+Quote Post
Cysiaczek
post
Post #17





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Co to ma wspólnego z OOP? Przenoszę na PHP
Go to the top of the page
+Quote Post
Fifi209
post
Post #18





Grupa: Zarejestrowani
Postów: 4 655
Pomógł: 556
Dołączył: 17.03.2009
Skąd: Katowice

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


Cytat(Cysiaczek @ 19.07.2009, 12:51:02 ) *
Co to ma wspólnego z OOP? Przenoszę na PHP


Może to, że __autoload służy do wczytywania klas, więc może tym autor kierował się zakładając wątek.
Go to the top of the page
+Quote Post

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: 23.08.2025 - 11:17