Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

parsing error - syntax error, unexpected T_NS_SEPARATOR [closed]

I have this line in PHP:

$bom != b"\xEF\xBB\xBF" 

When I run it, I get the error:

Parse error: syntax error, unexpected T_NS_SEPARATOR in
C:\xampp\htdocs\MediaAlbumWeb\Utils\Utils.php on line 218

What is the T_NS_SEPARATOR in php and why is it unexpected?

like image 960
Riaz Mahmood Rajib Avatar asked Sep 02 '25 13:09

Riaz Mahmood Rajib


1 Answers

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 != "b\xEF\xBB\xBF")
{
 //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
like image 91
Brendan Bullen Avatar answered Sep 05 '25 04:09

Brendan Bullen