S
S
sergeyviktorovich2021-01-23 16:55:43
1C-Bitrix
sergeyviktorovich, 2021-01-23 16:55:43

How to fix Cannot redeclare SopduPercent() error?

debug says that the error is in this file

<?php
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
function SopduPercent($Curse, $Percent){
    if(ctype_digit($Percent) || $Percent !== 0){
        $Summ = ($Curse/100*$Percent)+$Curse;
    } else {
        $Summ = $Curse;
    }
    $data = sprintf("%01.2f", $Summ);
    return $data;
}
include_once ('currency.php');
foreach ($arParams["ChoiceCurrency"] as $Params){
    $arResult[$currency[$Params]["ncode"]] = array(
        "code"      =>  $Params,
        "course"    =>  SopduPercent($currency[$Params]["money"], $arParams["ChoicePercent"]),
        "name"      =>  $currency[$Params]["name"],
        "num_code"  =>  $currency[$Params]["ncode"],
        "unit"      =>  $currency[$Params]["unit"]
    );
}
$this->IncludeComponentTemplate();
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2021-01-23
@sergeyviktorovich

Wrap this function in a condition

if(!function_exists('SopduPercent')) {
//.......
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question