Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
It is often confusing that how should we compare the strings and why should one be preferred over others. So to clarify this confusion here are few example which would give you a clear idea that what should be preferred over other.
The very basic approach what we follow is use of == equal operator for string comparisons. Here is why you should not use == equal operator going forward.
Code using == equal operator
string str1 = "something";
string str2 = "something";
if (str1 == str2)
//Works fine and statements are executed from this block