MyBB Community Forums

Full Version: [Tutorial] Adding an Online Location to your plugin.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Thanks for this Smile
(2009-09-01, 04:27 PM)Pirata Nervo Wrote: [ -> ]By the way, wouldn't strstr work too? (instead of preg_match)

strpos() works too and is faster than strstr (or preg_match). Wink
Use my_strpos.

Shy
(2009-09-03, 02:14 PM)Tomm M Wrote: [ -> ]Use my_strpos.

Shy

More information about my_strpos: http://crossreference.mybboard.de/inc/fu...html#l4053 Wink
I don't use strpos that much because if the position is 0 it will return 0 and if it fails it may return 0 as well
can be tricky
Not really, it's nice and simple as long as you use ===. Examples from PHP: http://uk2.php.net/function.strpos
Maybe that wasn't the function then, because I remember one that did the same or something similar but would return 0 in both cases.
I guess I should start using strpos then
It will return practically whatever it feels like returning, to be honest, so you're right - but if you use the === operator you can check whether it returns 0 (as in, it's there in the string but at the beginning) or whether it returns false (as in, it doesn't exist anywhere in the string).

It's not really a question of whether you should start using it or not - Toungue - it's up to you what you use!
Thanks for the suggestion Toungue
In PHP, 0 == false == "" == "0" == null and probably a few other things. A bit confusing perhaps, but just the way it works.

my_strpos is probably unnecessary as its main aim was to handle Unicode characters, whereas URLs generally don't have them, and even if they did, doesn't really matter (and you don't really care about the actual position given out anyway since you only care about if the string occurs or not).
Pages: 1 2 3