Search code examples
backbone.jsphp-7

PHP 7 "The ASP tags <%, %>, <%=" are deprecated


Per the manual: http://php.net/manual/en/language.basic-syntax.phptags.php

I'm trying to learn some various MVC's and frameworks (namely Backbone.js at the moment) and the pages the frameworks use are .html files and a code snippet would be listed as: <%- title %> (Source: https://github.com/tastejs/todomvc/blob/gh-pages/examples/backbone/index.html)

Does this mean the frameworks won't work if my server has PHP 7? I realize I could go ahead and just try it this individual time but I'm wondering...in general...does PHP 7 think the <% tags are ASP only and such not allow them?


Solution

  • The backbone should work without any problem with PHP, see example, because the code is wrapped is a script tag.

    <script type="text/template" id="tpl-hello-backbone">
        <%= message %>
    </script>
    

    In case that you still encounter problems try to use Mustache.js and display the text using {{}}

    <script type="text/template" id="tpl-hello-backbone">
           {{message }}
    </script>