0

All please download the index.php file from this link https://dl.dropboxusercontent.com/u/55806732/index.php Please run it the function getip() is not working. I have found out the reason. there is an invisible character. Solution: Please have closer look ,there is some space after "$_SERVER['REMOTE_ADDR'];" and it is also not "white space".If we remove that space then everything goes fine.

Question : I just need to know what is that invisible character, and how can i avoid these kind of errors in future? Is it depends on the IDE we are using.? What i can do if a page contains more than thousands of these entries?

<?php
function getip()
{

$dp = $_SERVER['REMOTE_ADDR'];                            
echo $dp;
}

getip();


?>
  • 4
    Please post code, we don't want to download anything. – maelswarm Feb 17 '14 at 10:14
  • Can you not simply post the problematic lines here? I don't think people will want to start running/downloading scripts.. – Lix Feb 17 '14 at 10:14
  • I did not viewed file, But I guess this problem due to editor and upload method ... – user1844933 Feb 17 '14 at 10:14
  • @Lix: posting the problematic lines here might actually lose relevant information (e.g. if the SO backend editor strips it). Some kind of a hex dump would be better. – DCoder Feb 17 '14 at 10:15
  • 2
    It's probably something to do with cut and pasting code from another program/file into your IDE - it's not likely to keep happening, unless you cut and paste a lot of code (wrist slap) and you should just remove them and be done with this problem. Compare this to when you try and cut and paste formatted text from MS Word into Notepad then upload that the the web and you see the disastrous results... P.s. there are already questions on SO about "invisible characters" – scrowler Feb 17 '14 at 10:17
  • @DCoder - you might be right, but trying to post it here would be better IMO than asking users to download and run scripts on their local machines... – Lix Feb 17 '14 at 10:17
  • 5
    This question appears to be off-topic because, rather than asking how to get the hexadecimal code of an invisible char, the OP is asking someone to do the job for him. – Álvaro González Feb 17 '14 at 10:17
  • @ÁlvaroG.Vicario I actually don't think your close flag is appropriate at all... "it is not a valid close vote and should perhaps be a comment" – scrowler Feb 17 '14 at 10:19
  • when i tried copy and paste the invisible character may get missed – ABHINAND V NAIR Feb 17 '14 at 10:22
  • 1
    https://hexdump.pieterhordijk.com/ – PeeHaa Feb 17 '14 at 10:23
  • @ Álvaro G. Vicario , this is not a job portal. I found the solution also, this is just to share the info. – ABHINAND V NAIR Feb 17 '14 at 10:23

2 Answers2

1

Quoting this answer:

"=C2=A0" represents the bytes C2 A0. However, since this is UTF-8, it translates to 00A0, which is the Unicode for non-breaking space.

You seem to have a UTF-8 encoded file that contains a non-breaking space. It looks like a space character; but PHP does not see it as a whitespace and it will complain about syntax error.

Community
  • 1
  • 1
Salman A
  • 262,204
  • 82
  • 430
  • 521
0

The hex code of invisible character is c2a0 This is causing the problem.

Akhilesh
  • 1,064
  • 15
  • 28