我在 Magento 中找到了正确的路径吗?
Am I getting the right path in Magento?
我愿意在 magento DATA.php 中 include/require 一个文件。
我有代码
public function formatPrice($price)
{
require_once(Mage::getBaseDir('app').'\design\frontend\neighborhood\default\template\catalog\product\view.phtml');
echo $Abowl;
}
但它们似乎没有工作,因为当您使用 require 时,如果无法读取文件,执行将停止。
我的问题是如何获取完整路径并将完整路径打印出来调试
更新 1
我试图像这样将 die() 函数应用到我的函数中:
public function formatPrice($price)
{
die( 'here!' );
require_once(Mage::getBaseDir('app').'/design/frontend/neighborhood/default/template/catalog/product/view.phtml');
echo $price;
}
但它仍然带来错误并给出如下图所示的结果:
ps:the 我在 Linux 中找到的路径:/var/www/html/app/design/frontend/neighborhood/default/template/catalog/category
顺便问一下,我还有一个关于如何访问 $price 的问题?
检查错误日志是否已启用:
root/var/log/exception.log
root/var/log/system.log
和 Apache 日志。
关于你的问题,如果找不到文件,require once 就会中断,所以你的问题是它没有被调用。在函数的顶部放置一个骰子以确保您可以进入:
public function formatPrice($price)
{
die( 'here!' );
require_once(Mage::getBaseDir('app').'\design\frontend\neighborhood\default\template\catalog\product\view.phtml');
echo $Abowl;
}
输出文件路径运行这样:
var_dump( Mage::getBaseDir('app').'\design\frontend\neighborhood\default\template\catalog\product\view.phtml' );
die;
我愿意在 magento DATA.php 中 include/require 一个文件。 我有代码
public function formatPrice($price)
{
require_once(Mage::getBaseDir('app').'\design\frontend\neighborhood\default\template\catalog\product\view.phtml');
echo $Abowl;
}
但它们似乎没有工作,因为当您使用 require 时,如果无法读取文件,执行将停止。
我的问题是如何获取完整路径并将完整路径打印出来调试
更新 1 我试图像这样将 die() 函数应用到我的函数中:
public function formatPrice($price)
{
die( 'here!' );
require_once(Mage::getBaseDir('app').'/design/frontend/neighborhood/default/template/catalog/product/view.phtml');
echo $price;
}
但它仍然带来错误并给出如下图所示的结果: ps:the 我在 Linux 中找到的路径:/var/www/html/app/design/frontend/neighborhood/default/template/catalog/category
顺便问一下,我还有一个关于如何访问 $price 的问题?
检查错误日志是否已启用:
root/var/log/exception.log root/var/log/system.log
和 Apache 日志。
关于你的问题,如果找不到文件,require once 就会中断,所以你的问题是它没有被调用。在函数的顶部放置一个骰子以确保您可以进入:
public function formatPrice($price)
{
die( 'here!' );
require_once(Mage::getBaseDir('app').'\design\frontend\neighborhood\default\template\catalog\product\view.phtml');
echo $Abowl;
}
输出文件路径运行这样:
var_dump( Mage::getBaseDir('app').'\design\frontend\neighborhood\default\template\catalog\product\view.phtml' );
die;