dox90448 2011-06-28 09:22
浏览 276
已采纳

即使页面中有类,PHP class_exists也没有回显输出

I'm trying to get a message to display if a class is present, not sure if I've got the right idea with this or not but it doesn't appear to be showing anything even though the class is there on the page.

<?php if (class_exists('quote-me')): ?>
<?php echo $this->__('View Quotation'); ?>
<?php endif; ?>

Can someone let me know if I'm on the right track.

  • 写回答

5条回答 默认 最新

  • dongseshu0698 2011-06-28 09:28
    关注

    class_exists() only checks if the class has been defined, not if you currently have an instance of that class. You could have the quote-me class defined and in scope, triggering the if block, but that by itself doesn't mean you have a valid instance of that class.

    Assuming that $this->__('View Quotation'); works if you have an instance, then the fact that it's not working could be an indication that you actually don't have an instance of the quote-me class in scope.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算