开发者

When using the Auth component with CakePHP, I keep getting this error. Why?

Warning (2): Cannot modify header information - headers already sent开发者_StackOverflow by (output started at /Applications/MAMP/htdocs/iframeworking/iframe/app/models/frame.php:7) [COREcake/libs/controller/controller.php, line 647]

here is the code from frame.php:

<?php
class Frame extends AppModel
{
    var $name = 'Frame';
var $belongsTo = array('User' => array('className' => 'User', 'dependent' => true));
}
?> 


You probably have a whitespace after your php closing tag (?>).

My recommendation is to make it a habit not to close your PHP tags in your controllers and models (and other PHP-only files). PHP parser does not require the closing tag at the end of the file (it is implied) and it will save you from headaches in the future (even though it will look "funny" at first).

In other words, this should fix it:

<?php
class Frame extends AppModel
{
    var $name = 'Frame';
    var $belongsTo = array('User' => array(/*...*/);
}


You are making an output to the web browser in /models/frame.php line 7. That is probably too early in the process - I don't know Cake, but I presume the model files should contain model classes only and no "active" code.

Note that even white space before the <? or <?php counts as output.


You have a whitespace after '?>' at the bottom. Removing that will fix the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜