ob_clean不会清理头文件之前的输出? [英] ob_clean doesn't clean the output before the header file?

查看:139
本文介绍了ob_clean不会清理头文件之前的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临这个问题。我改变了db.php文件,不幸的是我把php标签之前和之后的空格。我在image.php文件中使用这个。我得到错误头已经发送。我知道这是因为db.php中的空间,但我在image.php中使用了ob_clean。



以下是代码。

  spaceishere<?php 
$ con = mysql_connect(localhost,username,password)或die('我无法连接到数据库,因为:'。mysql_error());
mysql_select_db(dbname,$ con)或死(无法连接到数据库);
> andhere

image.php文件包含

 <?php 
require_once('db.php');
$ sql =mysqlquery;
$ query = mysql_query($ sql);
$ row = mysql_fetch_assoc($ query);
ob_clean();
header(content-type:image / jpg);
echo stripslashes($ row [imagecolumn]);
?>

当我删除db.php.php中的空格时,一切正常,但我无法理解为什么我的ob_clean无法正常工作。

你可以请任何人解释它,并且我不想更改db.php文件。因为我有问题。请不要请问这是什么问题。



我想在image.php中完成所有更改以使其正常工作。



请帮助解决这个问题。 (); 在包含之前。


I am facing the issue.I changed the db.php file and unfortunately I put the spaces before and after the php tags.I used this in the image.php file.I am getting the error header already sent.I know that it is because of the space in db.php but I used ob_clean in image.php.

Below is the code.

  spaceishere<?php
  $con=mysql_connect("localhost", "username", "password") or die ('I cannot connect to the           database because: ' . mysql_error());
  mysql_select_db("dbname",$con) or die  ("Cannot Connect to Database");
  ?>andhere  

image.php file contains the code of

<?php
require_once('db.php');
$sql="mysqlquery";
$query = mysql_query($sql); 
$row = mysql_fetch_assoc($query);
ob_clean();
header("content-type:image/jpg") ; 
echo stripslashes($row[imagecolumn]); 
?>

everything is working fine when I removed the spaces in db.php.But I cant able to understand why my ob_clean is not working.

Could you please anyone explain it.And I dont want to change the db.php file.Because I am having problem on it.Please dont ask whats the problem.

I want to done all my changes in image.php to make it work.

Please help on this.

解决方案

You should first start the output buffering by placing a call to ob_start(); before your inclusion.

这篇关于ob_clean不会清理头文件之前的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆