Juris Juris - 1 year ago 78
PHP Question

Why should I use strtolower() rather than mb_strtolower()?

I understand the usage/behaviour difference between

functions. And it has been asked before :)

But I don't understand - what is the current purpose of

Is it available because of backwards compatibility? Or is there some use cases when
is preferable? It seems that
is safer and more versatile so I am tempted to use it everywhere...

Answer Source

Not really backward compatibility, but the ability to use code wihtout additionally loaded multibyte string extension. So a question of portability of the code.

strtolower() is always available. mb_strtolower() is only available if the additional mbstring module is loaded. The function overloading feature allows to use the "generic" call to strtolower() which will actually execute mb_strtolower() if configured such. So there actually is no need to explicitly code mb_strtolower() at all...

This makes code more portable, since it can run on systems with or without the mbstring extension.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download