Home > Software design >  always starts from line 12
always starts from line 12

Time:08-30

My project always starts from line 12. What could be the reason for this? I am using codeigniter in my project.

MyController.php

public function test()
{
   echo "test";
}

enter image description here

CodePudding user response:

My first thought, is that you have line returns outside of your PHP tags.

for example

\n
<?php

Or

?>
\n

These will be output and can result in what you describe. The end tags ?> are optional. Unless of course it's mixed with HTML. Generally I never use them in pure PHP files.

These can appear in any files included by PHP prior to your output with echo. They can be very difficult to find and can cause issues with things like redirects and some file downloads as well because of the output. It's best to remove them.

  • Related