0

So I just spent 30 minutes trying to debug my code, when I finally understood that:

$words = array("word", "word", "word"); // doesn't compile
$words =array("word", "word", "word"); // Does compile

I just tried deleting the space between "=" and "array" as a sort of desperate random try and it worked. Is it a normal behaviour from PHP, considering usually the "=" instruction is totally fine with spaces?

7
  • 6
    PHP works just fine with that space after =. See here: 3v4l.org/0CBtX. You have something else going on. Commented Dec 5, 2013 at 16:40
  • 3
    The space isn't the issue here. What did the error you got say? Because chances are the character you deleted wasn't a space. It was probably some unicode character that just rendered like that. Commented Dec 5, 2013 at 16:42
  • 1
    I've seen things like this on every place and almost always it is about the user copy and paste the code from another place with some other encoding different from his own and when paste it, it came with some char that don't appear on the editor. Commented Dec 5, 2013 at 16:43
  • @RocketHazmat almost at the same time, same thought. Commented Dec 5, 2013 at 16:43
  • 1
    I just tried deleting and putting back the space in place, and the color in my editor was different. Then it worked. So yes it was probably a special character. That's strange though because I didn't copypaste that code... Thanks anyway Commented Dec 5, 2013 at 16:45

1 Answer 1

1

Ok it was some sort of special character that looks exactly like a space but wasn't one. Putting back a normal space worked.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.