duanlou2917
duanlou2917
2016-01-22 21:27

simplexml_load_file的语法错误

已采纳

I'm trying to append an item id from my database to an endpoint url within a simplexml_load_file function.

The function is called in the body section of an item page template that is part of a php mvc framework.

I've tried multiple different ways to fix the syntax error, and none seem to have worked.

Thanks in advance for your help.

[E_PARSE][Code 4] syntax error, unexpected '<'

My code:

<?php   

//call our items xml file and store in object
$myItems = simplexml_load_file('http://www.example.org/test/items.php?item_id=' . <?php echo $this->item['item_id']; ?>');

?>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • drydaenth257216154 drydaenth257216154 5年前

    Please change your code to following:

    <?php   
    
    //call our items xml file and store in object
    $myItems = simplexml_load_file('http://www.example.org/test/items.php?item_id=' . $this->item['item_id']);
    
    ?>
    

    you are not suppose to use <?php inside <?php

    点赞 评论 复制链接分享

相关推荐