Skip to content

Tag: php

Test if string could be boolean PHP

I’m getting a string from a $_GET and I want to test if it could be a boolean, before I use it for a part of a mysql query. Is there a better way of doing it than: Answer There’s, by the way, a cleaner way of writing it: But yes. The one you wrote down is the only way.

Building custom PHP extension (.so)

I own a high traffic website that does business in the USA and Canada. We have lots of servers but I want to make sure it’s 100% available with no latency whatsoever. I’ve learned about creating custom extensions (I know a little C) and I want to create custom validation/files (since php extension…

PHP XOR Decryption

I have an encrypted parameter V coming from a web page like this: V is encrypted like above: MD5 : XOR : which gives something like: what I want here is the function to decrypt this ‘ecryptedXOR’ using the password, so that I can get the: here’s what I’ve done so far: http://pastebin.c…

subtract 6 hours from date(‘g:i a’, strtotime($time_date_data));

I am using the following code to transform a universal time code into something a little more user friendly. But now I need to subtract 6 hours from meeting_time. Should I do it after the code above or can I work it into the same date function? Something like: Answer String-to-time (strtotime) returns a Unix …

Select Random Row from SQL Using PHP

I want to request 5 random rows from my SQL table using php. for instance, i need to: Answer Edit: For what its worth, Please note that using rand() on a table with large number of rows is going to be slow. This can actually crash your server. Some Solution: MediaWiki uses an interesting trick (for Wikipedia&…