Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: & w php 4.4.2
Forum PHP.pl > Forum > PHP
AxZx
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?
bim2
A nie
$obiekt = new klasa($sql, $smarty, $lang);
i
class klasa
{
function klasa(&$sql, &$smarty, &$lang)
{
...
nospor
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. ?>
AxZx
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. ?>
dr_bonzo
Wlasnie tak.
Na szczescie w piatce jest juz normalnie i nie ma babrania sie z "&".
bim2
Mógłbys rozszerzyć myśl normalnie? Nie trzeba & wstwiać?
Ludvik
PHP5 domyślnie przekazuje obiekty przez referencje. Zmienne innych typów są wciąż przekazywane poprzez wartość.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.