I recently discovered that the EE/CI's SLASH constant isn't the same as the "/" character. Or, at least, in my plug-in code, (SLASH == "/") evaluates to FALSE...

They output the same character, though. I'm confused... can anyone explain why this is the case?


That's because SLASH is actually the encoded form of /. Here's how it's set:

define('SLASH', '/');
  • Thanks, that make sense. I guess that means the constant isn't the best for use in regular expressions or [pre-parse] string replacements for templates. – Michael Rog Nov 27 '12 at 19:42
  • Yeah, I'd just ignore it, the EE core code does. Depending on what you're doing the DIRECTORY_SEPARATOR constant might be worth a look. – Dom Stubbs Nov 27 '12 at 19:53
  • 1
    AMP and other constants are also HTML-encoded. Always good to keep this in mind, they can be the cause of so many weird issues. – Adrian Macneil Nov 27 '12 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.