How do I “fix” php artisan?

久未见 提交于 2019-12-11 11:56:37

问题


I'm using Laravel 5. Whenever I type

php artisan tinker

I get the expected output preceded by a letter c:

cPsy Shell v0.5.2 (PHP 5.6.10-1+deb.sury.org~trusty+1 — cli) by Justin Hileman

Same happens when I type php artisan

The first line I get is the following:

cLaravel Framework version 5.1.16 (LTS)

Somehow that letter is displaying on all the views I have, so is messing up my project. When I click on "View Page Source" I see the letter 'c' before the "<!DOCTYPE html>" but I can't find it on any of my files.


回答1:


Try this trick:

put in a controller method of your choice this code:

header('x-my-header: whatever');

If all goes well PHP will fail to send the header, and write in the error message the file and the line where the output (the "c") started.

Note: this will not work if you're using output buffering.




回答2:


Probably you accidently typed "c" in the beginning of any source file that's always included (if not artisan itself:

c<?php

Now you can either replace the Laravel source with its original unmodified files or search for the above string, for example with:

rgrep  "c<?php" .

On a related note: Use a version control system like Git and you won't have these problems.




回答3:


I would suggest opening index.php and check there if there is some kind of echo "c"; or print "c";. As per your question and comment regarding that all your views have that letter seems like the index file or the main layout file is where the issue is. (I lean to the index.php file because you are seeing that letter before the doctype).



来源:https://stackoverflow.com/questions/32573866/how-do-i-fix-php-artisan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!