Well the reality is that I did write the class I provided. As someone who provides a “Premium” scripting site, you are opening yourself up to comments about the scripts you provide.
But what do you learn by copying and pasting a code?
Again, you are offering everyone to copy and paste your code, as well as that is the purpose of your site…
Further more, your second example would produce a ‘Notice’ Error. While you are correct that $i += 1 is marginally quicker than $i++, $i++ is quicker to type, and the differences are marginal. If you are worried about that marginal difference, than you will actually get more out of using ++$i than $i += 1;
And do people really want to optimize their website for a billion different devices, or the top10 devices that most people use for web surfing?
Really?!?.. You only need to optimize for mobile devices as a whole, not the individual devices. The irony of your scripts, is that they will only catch the mobile devices best equipped to view your ‘standard’ site, leaving the devices that most need a ‘mobile’ version to suffer through the standard site.
<?php
DetectMobileDevice::Mobile();
Returns true if a mobile device of false otherwise.
Apparently though, you consider %68 effectiveness, “getting the job done”.
I was simply adding my script so that others could then see another option.
If you can make my script better, then go for it. I am always looking to learn something new and improve my skills. I do not profess to know everything or even believe it on occasion.
What I know, I know. What I want to know is what I don’t know.
Now when people come to this Thread they will then have three options of how they want to address this issue. That is the underlining spirit of PHP; There is always another way of doing it. The option chosen depends on the circumstance and knowledge of the one implementing it.
I get frustrated when I see snippets that propagate bad techniques/practices. Even more frustrated when people think that a particular option is “99% of what this community needs”, you have them here, why not educate them a little more than the bare minimum. I appologize if you take offense to someone trying to show alternate methods.
NOTE strstr() is one of my biggest pet peeves, I apologize as it probably got me “going” a little more than a normal snippet would have. Another pet peeve is people using RegEx when they are not needed/optimal. Glad to see you’re not spreading that one.