0

I have an issue with my website. On every single page, there is an @ on top of each page that I didn’t write.

It seems to come from my config file. Indeed, I begin each page with require_once('config.php'), if I do echo 'test' before the require_once, I get :

test @

But if I echo 'test' after the require_once, I get:

@ test

I use Sublime Text (heard it could be an encoding error, tried to resave with Notepad++, nothing changed)

Have no idea what it can be.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
M0rkHaV
  • 432
  • 1
  • 4
  • 16
  • 3
    SOMEWHERE you'ev got a file that php is executing that has the `@` outside of the `` code blocks. You'll need to figure out where. We can't help you, since we have no idea of what your code is doing. – Marc B Jun 12 '14 at 17:23
  • 4
    Could you post your config file?(without passwords etc...) – Bioto Jun 12 '14 at 17:23

1 Answers1

1

I have posted about—and have dealt with—character encoding issues on many occasions. And the behavior you describe of you knowing the @ is coming from the config.php file by testing the echo 'test'; in require_once is not an encoding issue.

If this were an encoding issue, it would be garbage text/characters that would be at the top of the page or bottom of the page but could not be moved from those locations in the way you describe.

Somewhere in your config.php file there simply is an @ floating in there that is either:

  • The @ is outside the context of the PHP opening & closing tags (<?php/?>).
  • Something in your code is deliberately echoing a @.
  • Or—and this will be tricky—but depending on the complexity of your config.php file, it could be coming from another file that is being loaded via require_once or include within that config.php file.

The simplest thing to do right now is just open up the config.php file & do a search for the @ character. Look at each instance of that showing up & the context of the line it’s in. If you are lucky, you will spot something that seems odd.

Past that the best debugging tactic right now is to do the same echo 'test'; you did elsewhere solely in the config.php file itself.

  • First place that at the top of the config.php file & load the page.
  • Then place it at the bottom of the config.php file & load the page.
  • Then you might have to go from line-to-line to see if you can pin point it.
  • If you have to go from line-to-line, then split the difference. Go to the middle of the config.php and place the echo 'test'; there. Then based on what you see, keep on placing that either above or below the middle of the page.

Yes, this can be tedious. But it’s the best way to handle a case like this.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
  • I have already searched for @ and tried by commenting all included files. It doesn't come from there.. The weird thing is that my code works fine on my collegue's computer. We think it could be a local server issue. Thanks ! – M0rkHaV Jun 13 '14 at 08:01
  • 1
    Edit : Actually you were right, the @ was at the end of one of the file required in the config.php I don't know why but even when the required line was commented, I still had the @. Thx anyway ! – M0rkHaV Jun 14 '14 at 15:15
  • @user3655591 “I don't know why but even when the required line was commented.” It was at the end of the file? And it appeared commented out to you? But looked fine on a colleagues computer? Sounds like some kind of minor line-ending mix up. Meaning, Mac OS X, Windows & Unix all have slightly different ways to handle line endings. And if the page is not covered correctly, a stray “gremlin” line ending that mis-matches your machine got into the mix. So to you, it seems commented out. But in raw ASCII terms, the `@` was somehow preceded by a line ending that was essentially invisible. – Giacomo1968 Jun 14 '14 at 15:29
  • @user3655591 I posted another answer earlier this week on line ending issues here. Please read up on this so you can understand what believe might have happened to one of the files listed in your config file. http://stackoverflow.com/questions/24166800/php-problems-when-transfering-code-from-windows-to-os-x/24167027#24167027 – Giacomo1968 Jun 14 '14 at 15:31
  • 1
    Thks for the information. We are both on windows. We used source tree (git) for versionning. He switched on my branch so maybe there also was an issue there.. It definitly was a line ending issue anyway. You are certainly right as it was after the closing bracket ?> – M0rkHaV Jun 15 '14 at 20:34