![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 120 Pomógł: 1 Dołączył: 11.04.2005 Skąd: Poznań Ostrzeżenie: (0%) ![]() ![]() |
Odrazu mowie php 4.
Mam coś takiego index.php:
news.php:
initiate.php:
Czy moge jakoś ominąc odpalanie klas db i smarty w funkcji show (news.php) (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) Żeby odpalały się w pliku initiate.php bo dodawanie odpalania klas smarty i db za każdym razem jest troche uciążliwe. |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 853 Pomógł: 25 Dołączył: 27.08.2003 Skąd: Katowice Ostrzeżenie: (0%) ![]() ![]() |
widze 2 sposoby
1. global $db 2. wzorzec singleton |
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 627 Pomógł: 33 Dołączył: 1.05.2005 Skąd: Katowice Ostrzeżenie: (0%) ![]() ![]() |
1. swoją droga piszesz php4 a podajesz __construct(); ?!?
2. możesz przekazać odpalona klase db do klasy news np. $news = new news(&$db); a w klasie news w konstruktorze (w php4 o nazwie jak klasa) robisz $this->db = &$db; tak się kiedyś nauczyłem i tak mi zostało. nie wiem czy to jest prawidłowe postepowanie. (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) |
|
|
![]()
Post
#4
|
|
Grupa: Moderatorzy Postów: 1 566 Pomógł: 37 Dołączył: 14.05.2003 Skąd: Kraków ![]() |
|
|
|
![]()
Post
#5
|
|
Grupa: Zarejestrowani Postów: 120 Pomógł: 1 Dołączył: 11.04.2005 Skąd: Poznań Ostrzeżenie: (0%) ![]() ![]() |
Nie wiem co robie źle ale nie działa.
Cytat Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in C:\php\www\cms\news\index.php on line 28 Czemu __construct (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) poniewaz skrypt ma działać w php 4 i 5. A w 5 jest uławienie bo nie trzeba ładowć tej funkcji. |
|
|
![]()
Post
#6
|
|
Grupa: Przyjaciele php.pl Postów: 5 724 Pomógł: 259 Dołączył: 13.04.2004 Skąd: N/A Ostrzeżenie: (0%) ![]() ![]() |
Uzyj standardowego rozwiazania: http://pl.php.net/manual/en/language.oop5.decon.php
Cytat For backwards compatibility, if php 5 cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class. Effectively, it means that the only case that would have compatibility issues is if the class had a method named __construct() which was used for different semantics. --- Co do bledu -- ktora to linia?, i podaj naglowek funkcji ktora wywolujesz. Ten post edytował dr_bonzo 5.12.2005, 19:01:30 |
|
|
![]()
Post
#7
|
|
Grupa: Zarejestrowani Postów: 120 Pomógł: 1 Dołączył: 11.04.2005 Skąd: Poznań Ostrzeżenie: (0%) ![]() ![]() |
|
|
|
![]()
Post
#8
|
|
Grupa: Przyjaciele php.pl Postów: 5 724 Pomógł: 259 Dołączył: 13.04.2004 Skąd: N/A Ostrzeżenie: (0%) ![]() ![]() |
Zeby uproscic sprawe (wszystkie bledy poprawie od razu):
|
|
|
![]()
Post
#9
|
|
Grupa: Zarejestrowani Postów: 120 Pomógł: 1 Dołączył: 11.04.2005 Skąd: Poznań Ostrzeżenie: (0%) ![]() ![]() |
Dzieki już zrozumiałem oco chodzi i wszystko sobie poprawiłem i działa.
|
|
|
![]() ![]() |
![]() |
Aktualny czas: 22.08.2025 - 15:27 |