douyan1896 2015-06-22 21:37
浏览 17
已采纳

localhost和托管之间的Javascript差异

I have a php page that has some javascript, and for some reason the '<% ... %>' tags are behaving differently locally versus hosted. The relevant portion of code from my page is:

<script>

    var options = {
        segmentShowStroke: false,
        animateRotate: true,
        animateScale: false,
        percentageInnerCutout: 50,
        tooltipTemplate: "<%= value %>%",
        responsive: true,
        multiTooltipTemplate: '<%= datasetLabel %> - <%= value %>',
        labelsFilter: function (value, index) {
            return (index + 1) % 5 !== 0;
        }
    }

Locally, when I use firebug, I see this (which I want to see):

    var options = {
        segmentShowStroke: false,
        animateRotate: true,
        animateScale: false,
        percentageInnerCutout: 50,
        tooltipTemplate: "<%= value %>%",
        responsive: true,
        multiTooltipTemplate: "<%= datasetLabel %> - <%= value %>",


        labelsFilter: function (value, index) {
            return (index + 1) % 5 !== 0;
        }
    }

However when I put the page on my domain, and use firebug, I see this:

    var options = {
        segmentShowStroke: false,
        animateRotate: true,
        animateScale: false,
        percentageInnerCutout: 50,
        tooltipTemplate: "value%",
        responsive: true,
        multiTooltipTemplate: "datasetLabel - value",


        labelsFilter: function (value, index) {
            return (index + 1) % 5 !== 0;
        }
    }

It looks like 'tooltipTemplate' and 'multiTooltipTemplate' are being evaluated once before runtime when it is hosted, which is leading to unexpected results (hardcoded 'datasetLabel - value' instead of something like 'Net Worth - 100,000'

  • 写回答

1条回答 默认 最新

  • dounuo7954 2015-06-22 22:59
    关注

    the tags have changed with different php versions. you probably have different versions installed on the different systems.

    use the <?php opening tag, which is available on all versions.


    the following ASP tags <% , %> , <%= have been removed with php 7.

    7.0.0 ASP tags <% , %> , <%= , and script tag are removed from PHP.

    <?= can be used as of php 5.4.0

    5.4.0 The tag <?= is always available regardless of the short_open_tag ini setting.

    see PHP tags

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作