解析错误 - 语法错误,意外的T_NS_SEPARATOR [英] parsing error - syntax error, unexpected T_NS_SEPARATOR

查看:1013
本文介绍了解析错误 - 语法错误,意外的T_NS_SEPARATOR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PHP中有这行:

  $ bom!= b\xEF \xBB\xBF

当我运行它,我得到错误:

 解析错误:语法错误,
中的意外T_NS_SEPARATOR C:\xampp\htdocs\MediaAlbumWeb\Utils\Utils .php在线218

php中的T_NS_SEPARATOR是什么,为什么会出现意外?

解决方案

您的代码中可能有一个未封闭的单引号或双引号。



什么是超出引号的 b



如果是比较,可以这样:

  if($ bom!=b\xEF\\ \\ xBB\xBF)
{
//代码
}

在PHP中重现此错误的简单代码:

 <?php 
$ arg ='T'; //这个未封闭的双引号是完美的。

$ vehicle =($ arg =='B'?'bus':'not a bus');

print $ vehicle。\\\
; //这行上的错误被抛出

?>
/ pre>

运行它,它会打印一个错误:

  PHP解析错误:语法错误,意外的T_NS_SEPARATOR在
/var/www/sandbox/eric/code/php/run08/a.php第6行


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?

解决方案

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

这篇关于解析错误 - 语法错误,意外的T_NS_SEPARATOR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆