Escaping <? on php shorthand enabled server when using require

余生长醉 提交于 2019-12-02 06:24:19

问题


I'm trying to require() my template for rss feed in php. Unfortunately I need to have shorthand tags enabled on server I'm working with.

I have to start my rss with <?xml version="1.0" encoding="UTF-8" ?> and <? ... ?> confuses php into thinking he has to parse that line of code.

Is there a way to "escape" that?

here's just the full code of my rss template that I'm trying to include into main php file:

<?xml version="1.0" encoding="UTF-8" ?>
    <rss version="2.0">

    <channel>
    <title>Kokodakalo!</title>
    <link>http://127.0.0.1/koko/</link>
    <description>Usluga slična twitteru</description>
        <?php $data = $controller->getData(); foreach($data as $post):?>
        <?php require('views/Rss/item.part.v.htm');?>
        <?php endforeach;?>
    </channel>

    </rss>
</xml>

回答1:


For XML files, the <?xml version="1.0" encoding="UTF-8" ?> is optional (and actually the default like you write it), so you can just remove it and therefore could fix the problem for this case.




回答2:


You could <?php echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?>



来源:https://stackoverflow.com/questions/10457409/escaping-on-php-shorthand-enabled-server-when-using-require

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!