dongxie2756 2013-04-02 16:01
浏览 39
已采纳

ob_start()使用用户定义的函数内部出错

function d() {
            return "from d output
";

        }
        ob_start();
        //var_dump("any thing
");
        d();
        $a= ob_get_clean();
        echo "$a";

i'm starting doing things in php. I've used this code but in this case no output is being printed to the browser. But whenever I'm using code likevar_dump("anything "); within the two ob_ block I'm getting output. My question is what is the difference between the output of var_dump() and my handwritten function d() in this case?

  • 写回答

1条回答 默认 最新

  • doutao6653 2013-04-02 16:04
    关注

    Change this:

    d();
    

    ... into this:

    echo d();
    

    Invoking a function does not automatically print its return value. Or, if you want to mimic var_dump()'s behaviour:

    function d() {
        echo "from d output
    ";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行