phpcms syntax error,an unexpected errorT_IF

PHP syntax error, unexpected $end 错误的一种原因及解决
字体:[ ] 类型:转载 时间:
PHP 遇到 syntax error, unexpected $end 错误时,查错思路其实还是看看文件里 PHP 的开始标记和结束标记是否配对,还要额外注意注释里是否出现过 ?& 哟。
Parse error: syntax error, unexpected $end in script.php on line xx 调试了一会后发现产生错误的行是文件中间某行 //$str .= "?&\n"; 想起来了 PHP 解释器允许的结尾标记那行还可以用单行注释,即 //$str .= "?&\n"; 被解释成结尾标记前有注释,注释的内容是 //$str .= ",而 ?& 后面的 \n"; 会被解释作 PHP 块外的内容按 HTML 输出出去!结果是给 $str .= "?&\n"; 这行添加 // 成注释后,反而多了个 ?& 的结束标记,造成原来真正的结束标记成了意料之外的(unexpected)了。 解决办法就是直接删掉这一行即可。 PHP 开始和结束标记所在行别写其它东西,是个好习惯。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具查看: 10912|回复: 3
【已经解决】为什么提示: syntax error, unexpected T_STRING
插件名称:帮助
适用版本:v9
语言编码:GBK简体&
插件作者:
版权所属:
支持网站:
插件介绍:
适用版本号:无
本帖最后由 lilt2008 于
23:30 编辑
我是新得不能再新的人了,关照一下:
我按照V9的帮助文档学二次开发,按以下步骤做,却得到以下错误提示
错误提示:Parse error: syntax error, unexpected T_STRING in C:\AppServ\www\phpcms\modules\test\mytest.php on line 3
第一步:在phpcms/modules下建立一个“test”文件夹。
第二步:在phpcms/modules/test下建立一个mytest.php(书上说叫是控制器)。
第三步:在mytest.php中按教程写入以下内容:
  defined('IN_PHPCMS')
exit('No permission resources.');
  class mytest {
  function __construct()
    public
function init()
     $myvar =
'hello world!';
     echo $myvar;
    public
function mylist()
     $myvar =
'hello world!this is a example!';
     echo $myvar;
第四步:访问<font color="#7.0.0.1/index.php?m=test&c=mytest
访问就提示了: syntax error, unexpected T_STRING in C:\AppServ\www\phpcms\modules\test\mytest.php on line 3
请问我是哪里搞错了。帮帮我。
呵呵 ,把代码按照上面的写一下,里面有中文的空格。。
楼上的,谢谢你哈。
如果不是特殊模块的话,试试这个
Powered byhtml - Parse error: Syntax error, unexpected end of file in my PHP code - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
I got an error:
Parse error: syntax error, unexpected end of file in the line
With this code:
function login()
// Login function code
if (login())
&h2&Welcome Administrator&/h2&
&a href=\"upload.php\"&Upload Files&/a&
&a href=\"points.php\"&Edit Points Tally&/a&
echo "Incorrect login details. Please login";
Some more HTML code
What's the problem?
5,35651532
You should avoid this (at the end of your code):
You shouldn't put brackets directly close to the open/close php tag, but it separate with a space:
also avoid &? and use &?php
16.3k114558
I had the same error, but I had it fixed by modifying the php.ini file.
Look for a short_open_tag property, and apply the following change:
; short_open_tag = O previous value
short_open_tag = O new value
Just go to php.ini then find short_open_tag= Off set to short_open_tag= On
Check that you closed your class.
For example, if you have controller class with methods, and by accident you delete the final bracket, which close whole class, you will get this error.
class someControler{
public function method {
}// if you forget to close the controller, you will get the error
Avoid this as well &? } ?& make sure you put &?php } ?&
I saw some errors, which I've fixed below.
This is what I got as being erroneous:
if (login())
&h2&Welcome Administrator&/h2&
&a href=\"upload.php\"&Upload Files&/a&
&a href=\"points.php\"&Edit Points Tally&/a&
echo "Incorrect login details. Please login";
This is how I would have done it:
function login()
if (empty ($_POST['username']))
if (empty ($_POST['password']))
$username = trim ($_POST['username']);
$password = trim ($_POST['password']);
$scrambled = md5 ($password . 'foo');
$link = mysqli_connect('localhost', 'root', 'password');
if (!$link)
$error = "Unable to connect to the database server";
include 'error.html.php';
if (!mysqli_set_charset ($link, 'utf8'))
$error = "Unable to set database connection encoding";
include 'error.html.php';
if (!mysqli_select_db ($link, 'foo'))
$error = "Unable to locate the foo database";
include 'error.html.php';
$sql = "SELECT COUNT(*) FROM admin WHERE username = '$username' AND password = '$scrambled'";
$result = mysqli_query ($link, $sql);
if (!$result)
$row = mysqli_fetch_array ($result);
if ($row[0] & 0)
if (login())
echo '&h2&Welcome Administrator&/h2&
&a href=\"upload.php\"&Upload Files&/a&
&a href=\"points.php\"&Edit Points Tally&/a&';
echo "Incorrect login details. Please login";
some more html code
6,18682342
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you&#39;re looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled自始至终,以提供稳定、高性能的美国、香港免备案php虚拟主机产品为己任,以用户极高满意为生存价值,以产品的可靠性为生命线,以网络零中断为终身奋斗目标
内容管理系统是一款适合做企业站的系统,也有很多站长朋友在无忧主机上使用这个程序。最近无忧小编()遇到了好几次phpcms更新缓存后报错的问题,经过跟踪发现问题都是content_output.class.php文件的video($field, $value)方法没有生成完整,导致错误的出现。
那么问题来了,是什么问题造成类的生成不完整,经过排查,无忧小编()最终发现生成缓存文件的问题,找了半天,将问题锁定在了phpcms/modules/content/fields/video/output.inc.php
文件上面,这个文件经常会出现上传失败的情况,其实这个情况是跟无忧小编()遇到的一个情况是很像的,只是报错不太一样,详情可以参考:“”。
不过解决方法都是一样的,重新上传一个完整的/phpcms/modules/content/fields/video/output.inc.php
文件即可解决问题。
无忧主机相关文章推荐阅读:
本文地址:/phpcms/17096.html
喜欢本文或觉得本文对您有帮助,请分享给您的朋友 ^_^
无忧主机资质:(十二年旗舰品牌)
相关技术帮助文档
技术帮助文档分类

我要回帖

更多关于 织梦unexpected error 的文章

 

随机推荐