Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z funkcją, Cannot re-assign $this
a79rtur
post 14.11.2004, 18:00:02
Post #1





Grupa: Zarejestrowani
Postów: 331
Pomógł: 1
Dołączył: 23.05.2004
Skąd: Tarnów/Londyn

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


mam problem z następująca funkcją uzytą w pewnej klasie
wyskakuje błąd:

Fatal error: Cannot re-assign $this in ...

  1. <?php
  2.  
  3. function copy($other) {
  4. $xf = $this->_xf_index;
  5. $this = $other;  <-- ta linia 
  6. $this->_xf_index = $xf;  
  7. }
  8.  
  9. ?>

moze to php5 wina ,bo klasa nie najnowsza 2002r


--------------------
php 5.1.2 & Apache 2.0.50 & MySQL 4.1.7 @ WinXP Pro
..:: GG 6449856 ::..
www.londyn.me.uk - ogłoszenia mieszkaniowe dla Londynu
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
dr_bonzo
post 14.11.2004, 22:01:27
Post #2





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

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


  1. <?php
  2.  
  3. function copy($other) {
  4.         $xf = $this->_xf_index;   // Backup XF index
  5.         $this = $other;           // Copy properties
  6.         $this->_xf_index = $xf;   // Restore XF index
  7.     }
  8.  
  9. ?>


(http://search.cpan.org/src/JMCNAMARA/Spreadsheet-WriteExcel-0.37/WriteExcel/doc/WriteExcel.html):
Cytat
copy($format)

This method is used to copy all of the properties from one Format object to another:


    my $lorry1 = $workbook->addformat();
    $lorry1->set_bold();
    $lorry1->set_italic();
    $lorry1->set_color('red');    # lorry1 is bold, italic and red


    my $lorry2 = $workbook->addformat();
    $lorry2->copy($lorry1);
    $lorry2->set_color('yellow'); # lorry2 is bold, italic and yellow

It is only useful if you are using the method interface to Format properties. It generally isn't required if you are setting Format properties directly using hashes.

Note: this is not a copy constructor, both objects must exist prior to copying.


czyli ta funkcja probuje przypisac aktualnie uzywanemu obiektowi obiekt podany jako argument funkcji copy, jak widac jest to nieprawidlowe w php.

Cytat
This method is used to copy all of the properties from one Format object to another:


wiec moze obejdziesz sie bez tej funkcji (usun ja z kodu), lub przepisz ja tak zeby recznie skopiwac wszystkie "properties" (jak to jest po polsku?) z obiektu podanego w argumencie funkcji:
  1. <?php
  2.  
  3. $this->_font_index = $other->_font_index
  4. // ... itd az do
  5. //_right_color;
  6. // patrz poczatek tej klasy
  7. // niekopiuj tylko $this->_xf_index;
  8.  
  9. ?>


Nie sprawdzalem czy dziala!

---------------------------------------------------------
(http://www.ez.no/community/forum/install_configuration/installing_ez_publish_3_4_fatal_error_cannot_re_assign_this_in_ezdebug_php)
Cytat
Re: Installing eZ publish 3.4: "Fatal error: Cannot re-assign $this in ezdebug.php"
Posted on: Monday 21 June 2004 5:07:02 pm

We do not currently support PHP5. PHP5 will require some of the code to be rewritten, something we'll do when PHP5 is more widespread, and proven stable.

To jest chyba wina PHP5, 4ce bylo to chyba mozwliwe.

Ten post edytował dr_bonzo 14.11.2004, 22:26:19


--------------------
Nie lubię jednorożców.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 14:53