Can someone tell me why echo b"Test"; is working in php ?

  • 4
    Without testing it, my only assumption is the b is attempting to be used as a define() which doesn't exist and as these don't throw errors - only warnings, the code still outputs.
  • 0
    But why does that make sense in PHP 7 ?
  • 4
    @Grocker PHP7 still has backwards compatibility for some things. It's just how php is and always will be until these old things are actually removed and exceptions are thrown to actually deal with these things instead of logging an error.
  • 0
    Why shouldn't it work?
  • 1
    @olback For example echo a"Test"; does not works b is the only letter that works.
  • 3
    @Grocker I couldn't find any PHP docs about it. But it looks like c++ string literals. https://en.cppreference.com/w/cpp/...

    Edit: A similar thing exists in python I think.
  • 4
    @olback that's interesting.

    I was thinking it may have been a binary thing when @Grocker said it doesn't work for other letters

    Here's a SO answer to your question.
Your Job Suck?
Get a Better Job
Add Comment