Category Archives: PHP

PHP – Parse string into date and date comparison

// Get the date in string with Y-m-d format
$exp_date_s = "2013-04-22";
$today_s = date("Y-m-d");

// Convert the dates into timestamp
$exp_date = strtotime($exp_date_s);
$today = strtotime($today_s);

// Compare the timestamp
if ($exp_date > $today) {
  // Not yet expired
} else {
  // Expired
}

Done =)

Reference: Comparing Dates in PHP

About these ads

PHP – http:// wrapper is disabled in the server configuration by allow_url_fopen=0

If you find these 2 errors in the error log.

  • …file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in…
  • …failed to open stream: no suitable wrapper could be found in…

 

Edit the php.ini and enable the following 2 settings.

allow_url_fopen = On
allow_url_include = On

 

Restart Apache and they should be fixed.

Done =)

Reference:

Ubuntu – Install Memcached with PHP-FPM and Nginx

Previous: Ubuntu – Install APC with PHP-FPM and Nginx

Memcached is a distributed memory caching system and it caches data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read.

Like APC, the installation is simple.

1. Install Memcached.

  • apt-get install memcached

Continue reading

Ubuntu – Install APC with PHP-FPM and Nginx

Next: Ubuntu – Install Memcached with PHP-FPM and Nginx

APC stands for Alternative PHP Cache is a opcode which also known as machine code. The opcode is cached such that every time a request is sent to server, the same opcode is used until it detects a change in the PHP file.

Installation is easy and straight forward.

1. Install using apt-get.

  • apt-get install php-apc

Continue reading

Nginx – Enable Microcaching

Update @ 2013-05-09: I am not very sure if this could really enable the Nginx Microcaching as i couldn’t find the HIT value in the HTTP response. Please feel free to comment and let us know if you got the solution. Thanks. =D

Previous posts:

 

Enable Microcaching in Nginx could help making your website run much faster. Base on the setting we did in Nginx + PHP-FPM on Ubuntu Precise. Let’s edit the VirtualHost configuration file to enable Microcaching.
Continue reading