CodeIgniter Forums
Is it important??? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Is it important??? (/showthread.php?tid=11211)



Is it important??? - El Forum - 08-30-2008

[eluser]anggie[/eluser]
I just wanna know answer to this simple question...

Is it important to write :

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

I know what is it for, but when i add it to my controller, it show me a PHP error message :

Code:
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at E:\Dokumenku\xampp\htdocs\CodeIgniter\system\application\controllers\admin.php:3)

Filename: libraries/Session.php

Line Number: 315

Sorry...I am newbie...could you suggest any help??
Thanks...


Is it important??? - El Forum - 08-30-2008

[eluser]wiredesignz[/eluser]
Hi anggie, Welcome to CI forums.

The error is due to having `whitespace` outside the <?php ?> tags in your Controller file.

Anything outside the tags is considered as HTML and is output, so you get a `headers already sent` error.

It's common practice now, not to use the closing tag ?> in pure PHP files.

Hope this helps.


Is it important??? - El Forum - 08-30-2008

[eluser]anggie[/eluser]
Thanks wiredesignz!