PHP arrays are cool, but if you are switching to the modern coding standards (OOP) you are probably in need of objects more often.
PHP provides a very easy way to change the type of a variable from an array to an object. It’s done via typecasting.
Here’s an example:
// The actual conversion
$obj = (object) $arr;
echo $obj->name; // Will display John
This simple snippet of code will help you get the full URL of the currently viewed page.
$domain = $_SERVER['HTTP_HOST'];
$url = "http://" . $domain . $_SERVER['REQUEST_URI'];
The URL shortening service TinyURL.com provides an API for programmatically processing URL shortening requests through your own script. Continue reading “How to Dynamically Shorten URLs with TinyURL?”
Getting the thumbnail of a Youtube video through it’s ID is not that hard. You just have to transform the URL a little bit to get a high quality JPG file, used as a main thumbnail through Youtube.com. Continue reading “How to Grab Youtube Video Thumbnail?”
This is a simple tip but most experienced PHP programmers don’t know that it even exists. Continue reading “How to Assign the Same Value to Multiple Variables?”
Yes, Akismet can be of huge help when fighting with comment spam, but it can’t help against the most sophisticated auto-commenting tools which make fake comments look very real. Continue reading “Stop WordPress Comment Spam”