syntax error, unexpected T
I have this line in PHP:
$bom != b"xEFxBBxBF"
When I run it, I get the error:
Parse error: syntax error, unexpected T_NS_SEPARATOR in
C:xampphtdocsMediaAlbumWebUtilsUtils.php on line 218
What is the T_NS_SEPARATOR in php and why is it unexpected?
You likely have an unclosed single or double quote above that line in your code.
What is the b
that's outside of the quotes?
If it's a comparison, it could be something like:
if($bom != "bxEFxBBxBF")
{
//code
}
Simple code to reproduce this error in PHP:
<?php
$arg = "'T'; //this unclosed double quote is perfectly fine.
$vehicle = ( $arg == 'B' ? 'bus' : 'not a bus');
print $vehicle . "n"; //error is thrown on this line.
?>
Run this, it prints an error:
PHP Parse error: syntax error, unexpected T_NS_SEPARATOR in
/var/www/sandbox/eric/code/php/run08/a.php on line 6
You do a lot of Python, by any chance? b"string" is not a valid way to write your string in PHP, though it is in Python. If you just want the bytes, then you can write the string out as:
echo "xEFxBBxBF";
That works. If you want to check for inequality:
if( $bom != "xEFxBBxBF" ) {
}
What are you checking for anyway? For a Byte Order Mark? And if so: why, exactly?
链接地址: http://www.djcxy.com/p/11926.html上一篇: 输入中意外的字符:'\'(ASCII = 92)状态= 1
下一篇: 语法错误,意外的T