dongmen1860 2014-06-19 15:40
浏览 38
已采纳

Magento - 在phtml模板文件中包含/要求php文件

In one of my magento template phtml files I am trying to include a seperate php file. When I include it I get nothing outputted and when i use require instead I get the following error

Fatal error: require(): Failed opening required 'http://www.site.co.uk/dir/test.php'
(include_path='/home/usr/public_html/app/code/local:/home/usr/public_html/app/code/community:/home/usr/public_html/app/code/core:/home/usr/public_html/lib:.:/usr/lib/php:/usr/local/lib/php') in /home/usr/public_html/app/design/frontend/theme/edits/template/review/product/view/list.phtml on line 30

The first line of the error shows the correct url path and when i go to it directly it works - it just doesn't like being included/required from the phtml template page.

I've tried the following in the phtml file (using magento's BaseURL, absolute path and the relative path):

<?php 
$root = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
require/include ($root.'dir/test.php');
?>

<?php 
require/include ('http://www.site.co.uk/dir/test.php');
?>

<?php 
require/include ('../../../../../../../../../dir/test.php');
?>
  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 结构体数组文件读取问题
      • ¥15 写c++代码,第7题说一下使用的计算方法
      • ¥15 postman接口自动化测试报告实践总结
      • ¥15 有关c++的问题,利用相关知识
      • ¥15 求香农编码和解码的matlab代码
      • ¥20 ROS中的TEB局部规划问题
      • ¥20 关于#matlab#的问题:要求测出上面图片中所有同心圆的半径
      • ¥20 epanet软件运行问题
      • ¥15 Python 文件读取
      • ¥60 dpabi进行Alff计算时脑池有干扰信号