PHP函数未呈现为DOM

时间:2018-10-10 14:54:18

标签: php xml dom

请原谅我,我根本不了解PHP(但是在学习过程中!)无论如何,当页面加载而不是内容加载时,我可以看到脚本的残迹而没有内容。

enter image description here

我鞭打了检查器,并在标签中找到了此功能。

<div class="perfumesAvailable" >

    <? foreach($Content['content']['availablePerfumes']['availablePerfume'] as $key => $value){ ?>

如下所示,我包括了全部脚本:

<?php
$Buy = xml2array(file_get_contents(XML_PATH . 'retailers.xml'));
?>

<div  id="<?php
print($phpFileName);
?>">
    <div class="buynowMargin">

    <input type="hidden" name="lang" id="lang" value="<?php
echo $language;
?>" />
    <input type="hidden" name="perfume" id="perfume" value="" />

    <div class="wrapper">
        <a class="previous"></a>
        <a class="next"></a>
        <div class="perfumesAvailable" >

            <?php
foreach ($Content['content']['availablePerfumes']['availablePerfume'] as $key => $value) {
?>

               <div class="perfumeBottles event_buy_now_choose_product <?php
    echo $value['perfumeIdentifier']['value'];
?>" data-action-productid="<?php
    echo $language . '-' . $value['perfumeIdentifier']['value'];
?>">
                    <img id="<?php
    echo $value['perfumeIdentifier']['value'];
?>" src="<?php
    echo IMG_ROOT_URL . $value['productImage']['value'];
?>" alt="" title="<?php
    echo $value['perfumeName']['value'];
?>" />
                </div>
            <?
}
?>

        </div>

        <div class="selectPerfume">please select a perfume</div>
        <div class="shopRelated">
            <div class="notAvailable"><?php
echo $Content['content']['notAvailable']['value'];
?></div>
<?
php /*
<div class="notAvailableUS"><?php echo $Content['content']['notAvailableUS']['value']; ?></div>
*/ ;
?>

            <div class="backToShop">back</div>
            <div class="countrySelContainer">
                <div class="countrySelector"><span><?php
echo $Content['content']['selectCountry']['value'];
?></span></div>
                <select class="buyCountry" name="selectCountry" id="selectCountry">
                    <option label="<?php
echo $Content['content']['countries']['en-us']['value'];
?>" value="en-us" <?php
echo ($language == 'en-us' ? 'selected' : '');
?><?php
echo $Content['content']['countries']['en-us']['value'];
?></option>
                    <option label="<?php
echo $Content['content']['countries']['uk']['value'];
?>" value="en-gb" <?php
echo ($language == 'en-gb' ? 'selected' : '');
?><?php
echo $Content['content']['countries']['uk']['value'];
?></option>
                    <option label="<?php
echo $Content['content']['countries']['de']['value'];
?>" value="de" <?php
echo ($language == 'de' ? 'selected' : '');
?><?php
echo $Content['content']['countries']['de']['value'];
?></option>
                    <option label="<?php
echo $Content['content']['countries']['nl']['value'];
?>" value="nl" <?php
echo ($language == 'nl' ? 'selected' : '');
?><?php
echo $Content['content']['countries']['nl']['value'];
?></option>
                    <option label="<?php
echo $Content['content']['countries']['ru']['value'];
?>" value="ru" <?php
echo ($language == 'ru' ? 'selected' : '');
?><?php
echo $Content['content']['countries']['ru']['value'];
?></option>
                    <option label="<?php
echo $Content['content']['countries']['pt']['value'];
?>" value="pt" <?php
echo ($language == 'pt' ? 'selected' : '');
?><?php
echo $Content['content']['countries']['pt']['value'];
?></option>
                    <option label="<?php
echo $Content['content']['countries']['other']['value'];
?>" value="other" <?php
echo ($language == 'other' ? 'selected' : '');
?><?php
echo $Content['content']['countries']['other']['value'];
?></option>
                </select>
            </div>

            <div class="countrySelContainerSmall">
                <a class="countrySelectorSmall"><span><?php
echo $language == 'en' ? $Content['content']['countries']['en-us']['value'] : $Content['content']['countries'][$language]['value'];
?></span></a>
                <ul class="buyCountrySmall" id="selectCountrySmall">
                    <li class="en-us"><?php
echo $Content['content']['countries']['en-us']['value'];
?></li>
                    <li class="en-gb"><?php
echo $Content['content']['countries']['uk']['value'];
?></li>
                    <li class="de"><?php
echo $Content['content']['countries']['de']['value'];
?></li>
                    <li class="nl"><?php
echo $Content['content']['countries']['nl']['value'];
?></li>
                    <li class="ru"><?php
echo $Content['content']['countries']['ru']['value'];
?></li>
                    <li class="pt"><?php
echo $Content['content']['countries']['pt']['value'];
?></li>
                    <li class="other"><?php
echo $Content['content']['countries']['other']['value'];
?></li>
                </ul>
            </div>

            <div class="shopProductHeader bynight">
                    <span><?php
echo $Content['content']['shopProductHeader']['bynight']['value'];
?></span><br /><?php
echo $Content['content']['shopProductText']['value'];
?>
           </div>
            <div class="shopProductHeader definition">
                    <span><?php
echo $Content['content']['shopProductHeader']['definition']['value'];
?></span><br /><?php
echo $Content['content']['shopProductText']['value'];
?>
           </div>
            <div class="shopProductHeader glamx">
                    <span><?php
echo $Content['content']['shopProductHeader']['glamx']['value'];
?></span><br /><?php
echo $Content['content']['shopProductText']['value'];
?>
           </div>
            <div class="shopProductHeader redsin">
                    <span><?php
echo $Content['content']['shopProductHeader']['redsin']['value'];
?></span><br /><?php
echo $Content['content']['shopProductText']['value'];
?>
           </div>
            <div class="shopProductHeader signature">
                    <span><?php
echo $Content['content']['shopProductHeader']['signature']['value'];
?></span><br /><?php
echo $Content['content']['shopProductText']['value'];
?>
           </div>
            <div class="shopProductHeader touchofseduction">
                    <span><?php
echo $Content['content']['shopProductHeader']['touchofseduction']['value'];
?></span><br /><?php
echo $Content['content']['shopProductText']['value'];
?>
           </div>
            <div class="shopProductHeader unforgettable">
                    <span><?php
echo $Content['content']['shopProductHeader']['unforgettable']['value'];
?></span><br /><?php
echo $Content['content']['shopProductText']['value'];
?>
           </div>
            <div class="shopProductHeader violetnoir">
                    <span><?php
echo $Content['content']['shopProductHeader']['violetnoir']['value'];
?></span><br /><?php
echo $Content['content']['shopProductText']['value'];
?>
           </div>
            <div class="shopProductHeader woman">
                    <span><?php
echo $Content['content']['shopProductHeader']['woman']['value'];
?></span><br /><?php
echo $Content['content']['shopProductText']['value'];
?>
           </div>

            <div class="shopContainer">
                <div class="shopLogo"></div>
            </div>
        </div>
    </div>
<script type="text/javascript">
    $(document).ready(function(){
        setTimeout(function(){
        var windowW = $(window).width();
        var hash = window.location.hash;

        if(hash == '#bynight' || hash == '#definition' || hash == '#glamx' || hash == '#redsin' || hash == '#signature' || hash == '#touchofseduction' || hash == '#unforgettable' || hash == '#violetnoir' || hash == '#woman'){
            $("#perfume").val(hash.replace('#',''));
            getRetailers();
        }
        $(".perfumeBottles img").unbind('click').click(function(){
            $("#perfume").val($(this).attr("id"));
            getRetailers();
        });
        if((($(".buyCountry option:selected").val()) == 'de') || (($(".buyCountry option:selected").val()) == 'at') || (($(".buyCountry option:selected").val()) == 'sw')){
            if(windowW >= '1400'){
                $('.shopContainer').css('margin-left','25%');
                $('.shopContainer').css('margin-right','25%');
            }
        }
        if((($(".buyCountry option:selected").val()) == 'en-us') && ($("#perfume").val() == "woman")){
            $('.notAvailableUS').css('display','inline-block');
            $('.notAvailable').css('display','none');
        }else{
            $('.notAvailableUS').css('display','none');
        }
        $(".buyCountry").change(function(){
            if((($(".buyCountry option:selected").val()) == 'de') || (($(".buyCountry option:selected").val()) == 'at') || (($(".buyCountry option:selected").val()) == 'sw')){
                if(windowW >= '1400'){
                    $('.shopContainer').css('margin-left','25%');
                    $('.shopContainer').css('margin-right','25%');
                }
            }else{
                $('.shopContainer').css('margin-left','15%');
                $('.shopContainer').css('margin-right','15%');
            }
            $("#lang").val($(".buyCountry option:selected").val());
            getRetailers();
        });
        if(windowW <= '767'){

            //getRetailers();
            $('.buyCountrySmall li').click(function(){
                $('.buyCountrySmall li').removeClass('selected');
                $('.countrySelectorSmall span').text($(this).text());
                $("#lang").val($(this).attr("class"));
                $(this).addClass('selected');
                $('#selectCountrySmall').hide();
                getRetailers();
            });
        }
        },400);
    });
    function getRetailers()
    {
        $.post(
            "<?php
echo ROOT_URL;
?>templates/getRetailers.php",
                        {
                            data: "perfume="+ $("#perfume").val() +"&lang="+ $("#lang").val()
                        },
            function(json1)
            {
                if(json1.success == "success")
                {
                                    $(".buyProduct").removeClass("active");
                                    $("#"+json1.perfume).addClass("active");

                                    $("#lang").val(json1.lang);
                                    $("#perfume").val(json1.perfume);

                                    $(".shopContainer .shopLogo").html(json1.retailers);

                                    if(json1.retailers == ''){
                                        $('.notAvailable').css('display','inline-block');
                                        $('.shopProductHeader').css('line-height','0');
                                        $('.shopProductHeader').css('font-size','0');
                                        if($("#lang").val() == 'en-us' && $("#perfume").val() == 'woman'){
                                            $('.notAvailable').css('display','none');
                                            $('.notAvailableUS').css('display','inline-block');
                                        }else{
                                            $('.notAvailableUS').css('display','none');
                                        }
                                    }else{
                                        $('.notAvailableUS').css('display','none');
                                        $('.notAvailable').css('display','none');
                                        $('.shopProductHeader').css('line-height','24px');
                                        $('.shopProductHeader').css('font-size','22px');
                                        if((windowWidth <= 1023) && (windowWidth >= 768)){
                                            $('.shopProductHeader').css('line-height','13px');
                                            $('.shopProductHeader').css('font-size','13px');
                                        }
                                            if(windowWidth <= 767){
                                                $('.shopProductHeader').css('line-height','12px');
                                                $('.shopProductHeader').css('font-size','15px');
                                                if(windowWidth <= 479){
                                                   if($("#lang").val() == 'de'){
                                                    $('.shopLogo img').css('height','33px');
                                                    }
                                                }else{
                                                    if($("#lang").val() == 'de'){
                                                        $('.shopLogo img').css('height','40px');
                                                    }
                                                }
                                            }

                                    }
                }
            },
            "json"
        );
    }
</script>
    </div>
    <div class="buynowBackground"></div>
</div>

0 个答案:

没有答案