Upgrading to PHP 7.0 on Ubuntu 14

September 22, 2017

I upgraded PHP to version 7.0 on Ubuntu box. Running php -v on shell would show it as version 7.0. But Apache was still using PHP 5.6. I tried various methods to update settings for Apache but nothing worked until I issued following commands: <br /> sudo a2dismod php5.6<br /> sudo a2enmod php7.0<br /> sudo service apache2 restart<br /> Source: PHP 7.0 (and 5.6) on Ubuntu | LornaJane

Reading CSV File into PHP ARRAY

April 22, 2016

php
Useful: Here is a simple function that shows how to read our CSV file and return an ARRAY holding the data from the CSV. via Reading CSV File into PHP ARRAY.

Filter Some Keys in Multi-dimensional Arrays in PHP

April 22, 2016

php
/** * Cleans up multi-dimensional arrays. * 1st dimension is a simple index * 2nd dimension includes the desired keys * * @param mixed $array * @param mixed $keysToInclude */ public function cleanUpArray($array, $keysToInclude){ $returnArray = array(); $i = 0; foreach($array as $item){ foreach($keysToInclude as $key){ $returnArray[$i][$key] = $item[$key]; } $i++; } return $returnArray; }

PHP Programming on Chromebook

April 22, 2016

php
Here is my setup: Secure Shell – for accessing server and commiting code, ShiftEdit – probably the best and simplest web based PHP editor, BitBucket – for free private repos.

JSON_ERROR_CTRL_CHAR

April 22, 2016

I was using mcrypt to encrypt json_encoded data. On other side, mycrypt was able to decrpyt data but json_decode was not working. It would throw JSON_ERROR_CTRL_CHAR error. However, without mcrypt, json_decode worked flawlessly. After some trial and error, I found that applying trim function after decrypting data would let me use json_decode without any issues.

CodeIgniter Out Of Memory Error

April 22, 2016

php
Query Saving is a feature of CI’s database class that stores the results of every query in memory until the controller is finished executing. As it turns out, in version 1.6.0, the ability to turn this off was added. The addition of the save_queries variable is listed in the Change Log, but as of the latest release of 2.0.0 last week, it still hasn’t made the documentation. $this->db->save_queries = FALSE; via Undocumented CodeIgniter | Green Egg Media. ... Read more

CodeIgniter Creates a New Session with Each Page Load

April 22, 2016

php
Just spent 3 hours debugging a session bug in my webapp. CodeIginter was creating a brand new session with each page load. The issue was a misconfiguration with my config file. Fix was simple, in /application/config/config.php, make sure correct domain is set for $config['cookie_domain'].

© 2017 Amer Khalid