Welcome Guest, Not a member yet? Register   Sign In
$this->load->view() leaving blank line?
#1

[eluser]Unknown[/eluser]
Hello,

I have noticed a problem in codeigniter and I'm wondering what is causing it.

To replicated the error, from a fresh install of codeigniter I open up the welcome controller and edit it so it is as follows:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

/**
  * Index Page for this controller.
  *
  * Maps to the following URL
  *   http://example.com/index.php/welcome
  * - or -  
  *   http://example.com/index.php/welcome/index
  * - or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
public function index()
{
  $this->load->view('test');
}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

If I then open up views/test.php and put in some html so the file looks like this:
Code:
&lt;html&gt;
&lt;head&gt;
  &lt;meta http-equiv="content-type" charset="utf-8"&gt;
  &lt;title&gt;Test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
  <p>Test</p>
&lt;/body&gt;
&lt;/html&gt;

If I then load the application in the browser and view source, I can see the contents of views/test.php, but there is a blank line after &lt;/html&gt;. In the browser 'view source' I have 10 lines when views/test.php is only 9.

My question is how do I stop this blank line and only send the browser the code which is in view/test.php and get rid of the blank line?
#2

[eluser]InsiteFX[/eluser]
Correct HTML 5.
Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;

&lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;Test&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
    <p>Test</p>
&lt;/body&gt;

&lt;/html&gt;

I have seen all of users on here leaving out the the html doctype.




Theme © iAndrew 2016 - Forum software by © MyBB