Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> & w php 4.4.2, referencje?
AxZx
post
Post #1





Grupa: Zarejestrowani
Postów: 1 385
Pomógł: 55
Dołączył: 1.03.2005
Skąd: śląsk

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


witam

wlasnie zainstalowalem najnowsze z serii 4 php 4.4.2

takie ostrzezenia wyskakuja:

Kod
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 ...



tak przekazywalem zmienne do klasy
  1. <?php
  2. $obiekt = new klasa(&$sql, &$smarty, &$lang);
  3. ?>


jak to sie powinno robic?

Ten post edytował AxZx 26.06.2006, 11:25:41
Go to the top of the page
+Quote Post
bim2
post
Post #2





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


A nie
$obiekt = new klasa($sql, $smarty, $lang);
i
class klasa
{
function klasa(&$sql, &$smarty, &$lang)
{
...
Go to the top of the page
+Quote Post
nospor
post
Post #3





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




masz napisane w komunikacie bledu:
Cytat
If you would like to pass it by reference, modify the declaration of [runtime function name]()

Czyli:
  1. <?php
  2. function test(&$zm1, &$zm2){
  3. //....
  4. }
  5. ?>

i wywolanie:
  1. <?php
  2. test($zm1, $zm2);
  3. ?>
Go to the top of the page
+Quote Post
AxZx
post
Post #4





Grupa: Zarejestrowani
Postów: 1 385
Pomógł: 55
Dołączył: 1.03.2005
Skąd: śląsk

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


a klasa jak powinna wygladac?

tak dobrze?:
  1. <?php
  2. class ekartki{
  3.  
  4. var $sql;
  5. var $lang;
  6. var $smarty;
  7.  
  8. function ekartki(&$sql, &$smarty, &$lang){
  9.  
  10. $this->sql = &$sql;
  11. $this->smarty= &$smarty;
  12. $this->lang = &$lang;
  13.  
  14. }#koniec ekartki
  15. }
  16. ?>
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #5





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

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


Wlasnie tak.
Na szczescie w piatce jest juz normalnie i nie ma babrania sie z "&".
Go to the top of the page
+Quote Post
bim2
post
Post #6





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


Mógłbys rozszerzyć myśl normalnie? Nie trzeba & wstwiać?
Go to the top of the page
+Quote Post
Ludvik
post
Post #7





Grupa: Przyjaciele php.pl
Postów: 698
Pomógł: 3
Dołączył: 28.03.2004
Skąd: Wrocław

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


PHP5 domyślnie przekazuje obiekty przez referencje. Zmienne innych typów są wciąż przekazywane poprzez wartość.
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: 25.08.2025 - 05:56