To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Upgrading PHP

Upgrading PHP Issues concerning PHP version upgrades and future releases

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-14-2009, 05:29 AM   #1
hubm
Junior Member
 
Join Date: Oct 2009
Posts: 1
Fatal error: Cannot re-assign $this

Hi Everybody,I am a newbie.I have problem with my website,who can fix error for me :


<?php

function HitCounter()
{
$counter_file = "../count.txt";
if (($fp = fopen($counter_file, "r"))) {
$counter_b = (int) fread($fp,20);
fclose($fp);
} else {
$counter_b = "Non posso aprire il file";
return $counter_b;
}
$counter_a = $counter_b + 1;
$fp = fopen($counter_file,"w");
fwrite($fp,$counter_a);
fclose($fp);
return $counter_b;
}

function gb2unicode($gb)
{
if(!trim($gb))
return $gb;
$filename="gb2312.txt";
$tmp=file($filename);
$codetable=array();
while(list($key,$value)=each($tmp))
$codetable[hexdec(substr($value,0,6))]=substr($value,9,4);
$utf="";
while($gb)
{
if (ord(substr($gb,0,1))>127)
{
$this=substr($gb,0,2); $gb=substr($gb,2,strlen($gb));
$utf.="&#x".$codetable[hexdec(bin2hex($this))-0x8080].";";
}
else
{
$gb=substr($gb,1,strlen($gb));
$utf.=substr($gb,0,1);
}
}
return $utf;
}

function unicode_to_utf8($str) {

$utf8 = '';

foreach( $str as $unicode ) {

if ( $unicode < 128 ) {

$utf8.= chr( $unicode );

} elseif ( $unicode < 2048 ) {

$utf8.= chr( 192 + ( ( $unicode - ( $unicode % 64 ) ) / 64 ) );
$utf8.= chr( 128 + ( $unicode % 64 ) );

} else {

$utf8.= chr( 224 + ( ( $unicode - ( $unicode % 4096 ) ) / 4096 ) );
$utf8.= chr( 128 + ( ( ( $unicode % 4096 ) - ( $unicode % 64 ) ) / 64 ) );
$utf8.= chr( 128 + ( $unicode % 64 ) );

} // if

} // foreach

return $utf8;

} // unicode_to_utf8

function cutstring($mystring,$len){
// $mystring la xau can cat
$count=1;
$a="";
while ($count <=$len){
$pos = strpos ($mystring, " ");
$a=$a.substr($mystring,0,$pos+1);
$mystring=substr($mystring,($pos+1),strlen($mystring)-$pos);
$count++;
}
return $a;
}

function test($ngay)
{ $a='';
if ($ngay>2)
$a = $ngay.''.T1_ngay.'/ '.($ngay-1).' '.T1_night;
else if ($ngay==2)
$a= $ngay.''.T1_ngay.'/ '.($ngay-1).' '.T_night;
else
$a= '0'.T_ngay;

return $a;
}

function Processdate($strdate)
{
$year = substr($strdate,0,4);
$month = substr($strdate,4,2);
$day = substr($strdate,6,2);
if ($strdate == '') return '';
else

return $day.'/'.$month.'/'.$year;
}
?>

Error line 34
hubm is offline   Reply With Quote
Old 10-14-2009, 07:50 AM   #2
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,122
What the error message says. $this is a special variable that you can't just assign values to. Call it something else.

Also, since you're a Newbie, see the Guidelines in the Newbies' Forum.
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Weedpacket is offline   Reply With Quote
Old 11-03-2009, 03:26 AM   #3
rajeevbharti
Junior Member
 
Join Date: Oct 2009
Location: Delhi
Posts: 5
Quote:
Originally Posted by hubm View Post
Hi Everybody,I am a newbie.I have problem with my website,who can fix error for me :


<?php

function HitCounter()
{
$counter_file = "../count.txt";
if (($fp = fopen($counter_file, "r"))) {
$counter_b = (int) fread($fp,20);
fclose($fp);
} else {
$counter_b = "Non posso aprire il file";
return $counter_b;
}
$counter_a = $counter_b + 1;
$fp = fopen($counter_file,"w");
fwrite($fp,$counter_a);
fclose($fp);
return $counter_b;
}

function gb2unicode($gb)
{
if(!trim($gb))
return $gb;
$filename="gb2312.txt";
$tmp=file($filename);
$codetable=array();
while(list($key,$value)=each($tmp))
$codetable[hexdec(substr($value,0,6))]=substr($value,9,4);
$utf="";
while($gb)
{
if (ord(substr($gb,0,1))>127)
{
$this=substr($gb,0,2); $gb=substr($gb,2,strlen($gb));
$utf.="&#x".$codetable[hexdec(bin2hex($this))-0x8080].";";
}
else
{
$gb=substr($gb,1,strlen($gb));
$utf.=substr($gb,0,1);
}
}
return $utf;
}

function unicode_to_utf8($str) {

$utf8 = '';

foreach( $str as $unicode ) {

if ( $unicode < 128 ) {

$utf8.= chr( $unicode );

} elseif ( $unicode < 2048 ) {

$utf8.= chr( 192 + ( ( $unicode - ( $unicode % 64 ) ) / 64 ) );
$utf8.= chr( 128 + ( $unicode % 64 ) );

} else {

$utf8.= chr( 224 + ( ( $unicode - ( $unicode % 4096 ) ) / 4096 ) );
$utf8.= chr( 128 + ( ( ( $unicode % 4096 ) - ( $unicode % 64 ) ) / 64 ) );
$utf8.= chr( 128 + ( $unicode % 64 ) );

} // if

} // foreach

return $utf8;

} // unicode_to_utf8

function cutstring($mystring,$len){
// $mystring la xau can cat
$count=1;
$a="";
while ($count <=$len){
$pos = strpos ($mystring, " ");
$a=$a.substr($mystring,0,$pos+1);
$mystring=substr($mystring,($pos+1),strlen($mystring)-$pos);
$count++;
}
return $a;
}

function test($ngay)
{ $a='';
if ($ngay>2)
$a = $ngay.''.T1_ngay.'/ '.($ngay-1).' '.T1_night;
else if ($ngay==2)
$a= $ngay.''.T1_ngay.'/ '.($ngay-1).' '.T_night;
else
$a= '0'.T_ngay;

return $a;
}

function Processdate($strdate)
{
$year = substr($strdate,0,4);
$month = substr($strdate,4,2);
$day = substr($strdate,6,2);
if ($strdate == '') return '';
else

return $day.'/'.$month.'/'.$year;
}
?>

Error line 34

you are using $this as genera variable for assign value. that's why u are getting error message.
you can not use this as simple variable it is a key word which is used for specific purpous.

you are new in php you should read php manual in which there are all convention of variable declaring are defined.
rajeevbharti is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 08:24 AM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.