解析错误:语法错误,文件行43的意外结束(最后一行)

时间:2018-01-26 08:09:03

标签: php parse-error

我对此代码有疑问。有人在这里删除/改变了一些东西。我花了无数个小时试图找出我的位置;或者}可能会丢失,但没有运气。你能帮我吗?

<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Корзина");
?><?

if($_REQUEST['otkr'])
{
	Add2BasketByProductID(
		$_REQUEST['otkr'],
		1,
		array(),
		array(
				array("NAME" => "Текст открытки", "CODE" => "TEXT", "VALUE" => $_REQUEST['text_otkr'])
		)
	);
}

if($_REQUEST['pack'])
{
	Add2BasketByProductID(
		$_REQUEST['pack'],
		1,
		array(),
		array()
	);
}

?> <?$APPLICATION->IncludeComponent(
	"infoday:sale.basket.basket",
	"cart",
	Array(
		"COLUMNS_LIST" => array("NAME","PRICE","TYPE","QUANTITY","DELETE","DELAY","WEIGHT","DISCOUNT"),
		"COMPOSITE_FRAME_MODE" => "A",
		"COMPOSITE_FRAME_TYPE" => "AUTO",
		"COUNT_DISCOUNT_4_ALL_QUANTITY" => "Y",
		"GIFT_ID" => "",
		"HIDE_COUPON" => "Y",
		"PATH_TO_ORDER" => "/personal/order/make/",
		"PRICE_VAT_SHOW_VALUE" => "N",
		"QUANTITY_FLOAT" => "N",
		"SET_TITLE" => "Y"
	)
);?> <?if($USER->isAdmin()):?>&nbsp;&nbsp;<br>
 <br><?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>

2 个答案:

答案 0 :(得分:1)

你错过了endif;最后。

<?if($USER->isAdmin()):?>&nbsp;&nbsp;<br>
<br><?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
<? endif; ?>

你的代码风格很糟糕...为什么你在下一行开始一个新的(&lt;?)

时将html与php混合并结束php部分(?&gt;)

答案 1 :(得分:0)

我重新格式化了你的代码并在我的localhost上没有解析错误进行了测试:

<?php 
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Корзина");
?>

<?

if($_REQUEST['otkr'])
{
    Add2BasketByProductID(
        $_REQUEST['otkr'],
        1,
        array(),
        array(
                array("NAME" => "Текст открытки", "CODE" => "TEXT", "VALUE" => $_REQUEST['text_otkr'])
        )
    );
}

if($_REQUEST['pack'])
{
    Add2BasketByProductID(
        $_REQUEST['pack'],
        1,
        array(),
        array()
    );
}

?> 

<?php

$APPLICATION->IncludeComponent(
    "infoday:sale.basket.basket",
    "cart",
    array(
        "COLUMNS_LIST" => array("NAME","PRICE","TYPE","QUANTITY","DELETE","DELAY","WEIGHT","DISCOUNT"),
        "COMPOSITE_FRAME_MODE" => "A",
        "COMPOSITE_FRAME_TYPE" => "AUTO",
        "COUNT_DISCOUNT_4_ALL_QUANTITY" => "Y",
        "GIFT_ID" => "",
        "HIDE_COUPON" => "Y",
        "PATH_TO_ORDER" => "/personal/order/make/",
        "PRICE_VAT_SHOW_VALUE" => "N",
        "QUANTITY_FLOAT" => "N",
        "SET_TITLE" => "Y"
    )
);

?> 

<? 

if($USER->isAdmin()) : 
/* doing nothing here ??? */
endif
?>

&nbsp;&nbsp;<br>

<br>
<? 
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");

?>