Quantcast
Channel: Eureka! » PHP
Browsing all 16 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

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...

View Article


Image may be NSFW.
Clik here to view.

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...

View Article


Image may be NSFW.
Clik here to view.

Ubuntu – Install PECL uploadprogress PHP extension on Nginx

In Drupal, we can use a progress bar when uploading an image or file. But that needs a PHP PECL extension called uploadprogress. The following steps work for Ubuntu Precise (Ubuntu 12.04.1 LTS). 1....

View Article

Image may be NSFW.
Clik here to view.

PHP – Detect mobile device and do redirection

We can use PHP to detect the browser user agent such that it would redirect user to another URL if the request comes from a mobile device. 1. Create the user_agent.php. <?php $iphone =...

View Article

Image may be NSFW.
Clik here to view.

CentOS – Install Alternative PHP Cache (APC)

Haven’t worked with CentOS for a long time. Miss the time and the teammates in HKU CECID. Here are the steps to install Alternative PHP Cache (APC) on CentOS. 1. Install the following packages. yum...

View Article


Image may be NSFW.
Clik here to view.

PHP – Write file in specific charset/encoding

Sometimes we need to specify the file charset before writing the data to a file. The data strings which we get from the database are in UTF-8 so we have to convert them in proper charset. This could be...

View Article

Image may be NSFW.
Clik here to view.

PHP – http:// wrapper is disabled in the server configuration by...

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:...

View Article

Image may be NSFW.
Clik here to view.

PHP – String to DateTime and vice versa

// Assume you have a date string which is in d-m-Y format. $date_string = '18-04-2013'; // Create the DateTime object $date = date_create_from_format('d-m-Y', $date_string); // Print the date in Y-m-d...

View Article


Image may be NSFW.
Clik here to view.

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);...

View Article


Image may be NSFW.
Clik here to view.

PHP – Create multiple galleries in a single page using UberGallery

The UberGallery is a very handy PHP tool to create image galleries. After the setup, it will automatically detect the image files in the folder and generate the thumbnail view on the webpage. It also...

View Article

Image may be NSFW.
Clik here to view.

PHP – Sort a multidimensional array by specific key

Assume you have the following array in PHP. $myArray = array( 0 => array( 'hashtag' => 'a7e87329b5eab8578f4f1098a152d6f4', 'title' => 'Flower', 'order' => 3 ), 1 => array( 'hashtag'...

View Article

Image may be NSFW.
Clik here to view.

Composer – Manage your PHP dependencies

Mess up with the PHP dependencies in different environments? Composer is a PHP dependency manager where all the dependencies information are stored in the JSON file called composer.json. Similar to the...

View Article

Image may be NSFW.
Clik here to view.

Connect Drupal 8 RESTful Service with Guzzle PHP Web Service Client @ 1

Previously I have setup a a Drupal 8 which is RESTful ready. Drupal 8 – Setup the RESTful Service @ 1 Guzzle is a PHP HTTP client & framework for building RESTful web service clients. In this...

View Article


Image may be NSFW.
Clik here to view.

Drupal 8 – Login in Guzzle Web Service Client @ 1

1. Get your PHP client ready by following my previous post. Connect Drupal 8 RESTful Service with Guzzle PHP Web Service Client @ 1   2. Update your index.php as follow. <?php require...

View Article

Image may be NSFW.
Clik here to view.

Drupal 8 – Create a node through RESTful Web Service @ 1

In the previous posts, we have gone through some examples about working with Drupal 8 RESTful web service. Drupal 8 – Setup the RESTful Service @ 1 Connect Drupal 8 RESTful Service with Guzzle PHP Web...

View Article


Image may be NSFW.
Clik here to view.

PHP – Insert and element into a specific position of an Array

Originally we have an array as follow $fruits = array( '0' => 'apple', '1' => 'banana', '2' => 'pear', );   So i want to insert “melon” into the 2nd position which is after “apple”. We can do...

View Article
Browsing all 16 articles
Browse latest View live