mySQL Timestamp convert to RSS PubDate:
$year = substr($timestamp, 0, 4);
$month = substr($timestamp, 4, 2);
$day = substr($timestamp, 6, 2);
$hour = substr($timestamp, 8, 2);
$min = substr($timestamp, 10, 2);
$sec = substr($timestamp, 12, 2);
$pubdate = date(‘D, d M Y H:i:s O’, mktime($hour, $min, $sec, $month, $day, $year));
even better way:
<?php $pubdate = date(‘D, d M Y H:i:s O’, strtotime($timestamp)); ?>
via mySQL Timestamp convert to RSS PubDate – PHP Code Snippet.
PHP supports MySQL using a PHP extension. Thousands or millions projects have been written worldwide using PHP and MySQL. PHP team announced plans to deprecate MySQL extension in mid 2011. Old MySQL extension officially deprecated since PHP 5.5.0 in late 2012 and it will be removed in the future. The alternatives since PHP 5 and later are MySQLi (“i” stands from “improved”) and PDO (PHP Data Objects).
Everyone can understand that is not so easy to immediately migrate old projects. However, the old extension must not be used anymore in new development.
Old extension didn’t support Prepared Statements. Both MySQLi and PDO are object oriented and do support Prepared Statements (also support Transactions, Stored Procedures and more). Prepared Statements are very important for web application security, as they protect from SQL injection. Using Prepared Statements you do not have to escape strings before insert them in Database. Moreover, PDO offers support for many databases (not only MySQL).
So, the question is “Which Should I Use? MySQLi or PDO?”. A short answer would be “whatever you like”. Personally, I prefer MySQLi. I could select PDO if “multiple database support” was included in project requirements (however, in this case php ADODB could also be an alternative).
Below I describe the common use of MySQLi in php development with MySQL database (it can be also used with MariaDB, an enhanced, drop-in replacement for MySQL).
How to Use PHP Improved MySQLi extension (and Why You Should).
I have been looking for a lightweight framework to build a RESTful API in PHP. There are a number of good options out there: Slim, Epiphany, Tonic, Recess, and Frapi to name a few. They all seem like good frameworks. In the end, I chose Slim for this project for two main reasons:
- It’s very lightweight and focused on REST and nothing else.
- It supports all the HTTP methods (GET, POST, PUT, DELETE), which was a key requirement for my application.
RESTful services with jQuery, PHP and the Slim Framework | Christophe Coenraets.
Especially to my students, this is a good resource learning object-oriented programming for beginners in php:
Object-Oriented PHP for Beginners – Tuts+ Code Tutorial.
rss readers classes written in php:
PHP Master | Consuming Feeds with SimplePie.
For several reasons I’d like to keep my dynamic IP instead of install a static IP, but I had to use a service such as easydns.com, no-ip.org etc. The only thing I was needed was just the current IP of my home router. So, I had this simple idea which when the linux box detects an IP change, then the script updates the web page. So, when I want to get informed about the ip of my home router, I’m visiting the address example.com/myip/index.php. For this, I made a php script which runs nicely. Continue reading Track your Dynamic IP