解析错误:语法错误,意想不到的T_STRING [英] Parse error: syntax error, unexpected T_STRING

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

问题描述

我不断收到这个T_STRING解析错误林不知道它是什么,但其对朝底线34,任何帮助是AP preciated。

 <形式的行动=PRODUCT_SEARCH>
<输入类型=文本名称=搜索VALUE =&LT ;?回声ヶ辆($ _ GET ['搜索']);?>/>
<输入类型=提交值=搜索/>
< /表及GT;
&LT ;?
$ search_items = urlen code($ _ GET ['搜索']);
// $ search_items ='EEE';
$项目=使用simplexml_load_file('http://api.shopping.com/dsp/linkin_id-8005272/keyword-'.$search_items);如果(($项目)及及(strlen的($ search_items)→1)){
打印< pre> \\ N的;
的foreach($物品─> result->结构域> {域上市} $作为项目){
打印L($本期特价货品>标题,$本期特价货品> URL)< BR />中。
}
打印'< / pre>';
}
其他{
?>
搜索产品 - 电脑,华硕Eee电脑,准笔记本电脑,以及所有伟大的东西!
&LT ;?
}
?>&LT ;?
$ TIDS =爆炸(,,ARG(2));
的foreach($ TIDS为$ TID){
$ term_info = taxonomy_get_term($ TID);
$ search_items = urlen code($ term_info->名);
$项目= simplexml_load_file('http://publisher.api.shopping.com/publisher/3.0/rest/GeneralSearch?identity.apiKey=[API KEY]&安培; tr.trackingId = [ID LINKIN&安培; nf.keyword ='​​$ search_items)。如果(($项目)及及(strlen的($ search_items)→1)){
的foreach($物品─>&组别GT;&类别 - GT;&物品─GT;要约$项目){
打印'< D​​IV的风格=浮动:左;宽度:120像素;填充:10px的;溢出:汽车;显示:块;>';
//这里是错误
打印'<一个相对=nofollow的onclick =JavaScript的:_gaq.push(['_ trackPageview的','/出/ article_exit_link / 789591']); HREF ='$本期特价货品> offerURL属性。'>< IMG SRC ='$本期特价货品> imageList->图片[0] - > sourceURL'WIDTH =100&GT ;&所述; / A>';
打印< BR />中L($本期特价货品>的名字,$本期特价货品> offerURL属性,阵列(),NULL,NULL,TRUE)。
打印'< / DIV>';
}
}
}
?>


解决方案

您必须要小心你的单,双引号。在那行,你有

 '<一个相对=nofollow的onclick =JavaScript的:_gaq.push(['

这打开和关闭的字符串。在_trackPageview然后导致错误,因为它不是字符串的一部分。

您可以试试下面像(未经测试):

 打印'<一个rel =nofollow的的onclick =JavaScript的:_gaq.push([\\'_ trackPageview的\\',\\'/呼出/ article_exit_link / 789591 \\']) ; HREF ='。$本期特价货品> offerURL属性\\'\\>< IMG SRC =\\'$本期特价货品> imageList->图片[0]  - > sourceURL \\'WIDTH = 100>&下; / A>';

通过之前每个'添加\\,你逃避它,这样它被认为是您的字符串的一部分。

I keep getting this T_STRING Parse error im not sure what it is but its on line 34 towards the bottom, any help is appreciated.

<form action="product_search">
<input type="text" name="search" value="<? echo htmlentities($_GET['search']); ?>"/>
<input type="submit" value="Search"/>
</form>
<?
$search_items = urlencode($_GET['search']);
// $search_items = 'eee';
$items = simplexml_load_file('http://api.shopping.com/dsp/linkin_id-8005272/keyword-'.$search_items);

if (($items) && (strlen($search_items) > 1)) {
print "<pre>\n";
foreach ($items->result->domain->{domain-listing} as $item) {
print l($item->title, $item->url)."<br/>";
}
print '</pre>';
}
else {
?>
Search for products-- computers, eee pcs, sub-notebooks, and all that great stuff!
<?
}
?>

<?
$tids = explode(',',arg(2));
foreach ($tids as $tid) {
$term_info = taxonomy_get_term($tid);
$search_items = urlencode($term_info->name);
$items = simplexml_load_file('http://publisher.api.shopping.com/publisher/3.0/rest/GeneralSearch?identity.apiKey=[API KEY]&tr.trackingId=[LINKIN ID]&nf.keyword='.$search_items);

if (($items) && (strlen($search_items) > 1)) {
foreach ($items->categories->category->items->offer as $item) {
print '<div style="float: left; width: 120px; padding: 10px; overflow: auto; display: block;">';
//right here is the error
print '<a rel="nofollow" onclick="javascript:_gaq.push(['_trackPageview', '/outgoing/article_exit_link/789591']);" href="'.$item->offerURL.'"><img src="'.$item->imageList->image[0]->sourceURL.'" width="100"></a>';
print "<br/>".l($item->name, $item->offerURL, array(), NULL, NULL, TRUE);
print '</div>';
}
}
}
?>

解决方案

You have to be careful with your single and double quotes. On that line, you have

'<a rel="nofollow" onclick="javascript:_gaq.push(['

That opens and closes your string. the _trackPageview then causes the error, as it is not part of the string.

You can try something like (untested) below:

print '<a rel="nofollow" onclick="javascript:_gaq.push([\'_trackPageview\', \'/outgoing/article_exit_link/789591\']);" href="\'.$item->offerURL.\'"><img src="\'.$item->imageList->image[0]->sourceURL.\'" width="100"></a>';

By adding a \ before each ', you escape it so that it is considered part of your string.

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

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