This is the official* page on BuckysRoom for the PHP programming language. You can use this page to post cool stuff that you're learning about PHP, ask questions, and share why you love (or hate) the language. Enjoy! *whatever

June 28, 2014 · Public

What's the best and worst thing about PHP?

June 3, 2014 · Public

Someone should create a PHP library that shortens function names:

file_get_contents could go to fgc
file_put_contents could go to fpc
mysql_connect could go to mc
mysql_real_escape_string could disappear completely
file_exists -> fe
get_html_translation_table should be ghtt or something similar

May 14, 2014 · Public

PDO vs. MySQLi

Does anyone have any experience with which is better for working with databases in PHP? I personally use PDO whenever possible, but I'd like to hear what other people prefer and why.

Let me know!

May 14, 2014 · Public

I've seen a lot of PHP programmers use the following syntax for checking if multiple variables are set with the isset() function.

if( isset( $_POST["fname"] ) AND isset( $lname ) )
//Do Something

However, the isset() function can take multiple parameters and will only return TRUE if all are set and not equal to NULL. The above code could be simplified to:

if( isset( $_POST["fname"], $lname ) )
//Do Something

I hope that this helps someone out there!

April 29, 2014 · Public

Here's an awesome PHP trick that I learned recently that has saved me a lot of time!

Usually, when working with form data, one has to test to see if a POST (or GET) variable has been set before testing to see if it is equal to some value or otherwise using it in a program.


if( isset($_POST["fname"]) && ( $fname = $_POST["fname"] ) == "John" )
//Do Stuff with $fname

Isn't that terribly long? The truth is that you can do it much more easily by:

if( ( $fname = &$_POST["fname" ]) == "John" )
//Do Stuff with $fname

This trick has saved me a lot of typing, and if the POST variable doesn't exist, $fname will have a value of NULL.

The reason that you need the '&' is because PHP gives nasty error messages if it can't find an array element, and asking for the reference of a non-existent element returns NULL without errors.