我如何将PHP代码推送到js变量?

时间:2017-01-17 12:48:03

标签: javascript php

我想把这个PHP代码推送到javascript变量就像一个字符串, 它可以吗?     

$APPLICATION->IncludeComponent("wt:static.content", "bonus10", array(
        "DEFAULT_LANG" => array(
        0 => "",
),
    "LANGUAGE_ID" => "",
    "USE_DEFAULT" => "Y",
    "INCLUDE_LANGUAGE" => "",
    "CACHE_TYPE" => "Y",
    "CACHE_TIME" => "3600"
),
false,
array(
    "ACTIVE_COMPONENT" => "Y",
    "HIDE_ICONS" => "N"
)
);
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>

1 个答案:

答案 0 :(得分:2)

var string = '$APPLICATION->IncludeComponent("wt:static.content", "bonus10", 
                                            array("DEFAULT_LANG" => array(0 => "",),
                                            "LANGUAGE_ID" => "",
                                            "USE_DEFAULT" => "Y",
                                            "INCLUDE_LANGUAGE" => "",
                                            "CACHE_TYPE" => "Y",
                                            "CACHE_TIME" => "3600"),
                                            false,array("ACTIVE_COMPONENT" => "Y",
                                                            "HIDE_ICONS" => "N"));
                                                            require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php"‌​);?>';