Forum Moderators: coopster

Message Too Old, No Replies

I'm Getting a Parse Error in my Code

Unexpected T_LNUMBER

         

naitsirhc26

10:08 am on Nov 18, 2007 (gmt 0)

10+ Year Member



Hello,

I am getting the following error code on my blogging system:

Parse error: parse error, unexpected T_LNUMBER in /formatting.php on line 90

Here is the code I have for that formatting.php script:

function seems_utf8($Str) { # by bmorel at ssi dot fr
for ($i=0; $i<strlen($Str); $i++) {
if (ord($Str[$i]) 0x80) continue; # 0bbbbbbb // this is line 90!
elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb
elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb
elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb
elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb
elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b
else return false; # Does not match any model
for ($j=0; $j$n; $j++) { # n bytes matching 10bbbbbb follow?
if ((++$i == strlen($Str)) ¦¦ ((ord($Str[$i]) & 0xC0)!= 0x80))
return false;
}
}
return true;
}

Do you happen to see where my syntax error in the code is located?

Thanks in advance,

Christian

Habtom

10:13 am on Nov 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if (ord($Str[$i]) && 0x80) continue; # 0bbbbbbb // this is line 90!

naitsirhc26

10:30 am on Nov 18, 2007 (gmt 0)

10+ Year Member



Thank you for the quick reply! After I implemented your fix, it gave me the same error but for line 97, which would be this line of code:

for ($j=0; $j$n; $j++) { # n bytes matching 10bbbbbb follow?

It's looking to me like that entire bit of code I sent out is a bit hacked by the person that created it!

Habtom

11:07 am on Nov 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$j$n

Needs to be:
$j<$n

You need to check if the overall code does what you want to do.

Also . . .
if ((++$i == strlen($Str)) ¦¦ ((ord($Str[$i]) & 0xC0)!= 0x80)) {
return false;
}

(opening curly bracket { was missing.)

[edited by: Habtom at 12:02 pm (utc) on Nov. 18, 2007]

vincevincevince

11:42 am on Nov 18, 2007 (gmt 0)