9

Php functions strcmp, strcasecmp and other from this family are binary-safe.

Are operators == and === binary-safe?

And if yes what should be used in binary-safe string comparison: functions or operator?

(binary-safe: "operator or function that can be applied to variables without altering their current state")

2 Answers 2

7

They are, by your definition, but if you're comparing strings containing binary data, you should be aware of the fact that in PHP $a == $b can return true even when $a and $b are different. Example: "2e2" == "200"

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

Comments

5

All Comparison operators are binary safe and == and ===(compares with type ) are comparison operators so they are .......

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.