4
Grocker
6d

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

Comments
  • 2
    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 ?
  • 2
    @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.
  • 2
    @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.
    https://stackoverflow.com/a/4749553
Your Job Suck?
Get a Better Job
Add Comment