Posts tagged applications
ctype_digit rtfm!
1For the last 5-10 minutes I've been wondering why a check on a variable which should be valid has been returning false.
The check is ctype_digit, which returns true if all characters in a string are digits.
So if $var = 1;, you might expect it to return true, but it doesn't.
Why not? Well, as the PHP manual states, this function acts on strings not integers.
Therefore checking something that has been specifically set as an integer (as in the example above) or typecast to be an integer at some point (as is my case) ctype_digit will fail as the data it is checking is not a string in the first place!
So there you go. Although 99% of data handled in PHP is in string form at some point, and therefore a ctype_digit check is generally completely valid, in some special cases it might be worth combining a ctype_digit() check with a preceding is_string() check depending on your application.
Rant over...
2 New Facebook Apps Begun
0Today I have started writing 2 new Facebook applications, Doomsday Device and Game Stats.
You can find out more about each by visiting the following development blogs:
Starting App’s For Facebook
3Yesterday for a bit of fun I decided I'd try and write my first application for facebook - and I have to say the setup based on the example code they give you is pretty straightforward, however it could do with some extra vital documentation.
What would be in this documentation you ask?
You might think, "being a social networking site users may want to upload photos or other files to your app. for various reasons", so lets make that side of things easy and secure.
Well obviously facebook didn't, and as such seem to have turned off/prevented access to PHP's $_FILES array and don't mention it anywhere obvious.
This is annoying as it wasn't really mentioned anywhere and, after all, your app is essentially it's own self contained program sitting on it's own server somewhere which obeys it's own set of rules and just appears on facebook by means of, what can only be described as an extended iframe, so why should they prevent access?
In fact file upload is possible but you have to do it via some convoluted method where you mime encode the file and send it through via POST, which is a pain.
Though I spent 3 hours or so trying to work out why my app wasn't receiving files before finding this out, that hasn't deterred me and you can expect some more posts about Facebook app building here as soon as I have time to write them