PHP

php

PHP Password Functions In 5.5

Tuesday, March 4, 2014 - 23:14

New in PHP 5.5 is a group of functions that deal with password hashing and verification. This is such a common thing for PHP applications to do that it was decided to include it into the core of PHP. They effectively solve the problem of hashing and comparing passwords that just about every PHP developer has implemented at one point or another.

There are only a few functions available but they provide all of the functionality needed to create a hash value from a password, check if the hash is valid and to check if the password hash needs to be recreated.

Category: 

The Monty Hall Problem In PHP

Tuesday, September 24, 2013 - 10:10

The Monty Hall problem is a counter intuitive problem in probability mathematics that deals with picking the right prize from a set of three doors. The problem is named after the television celebrity Monty Hall and is loosely based on the USA game show Let's Make a Deal.

Category: 

Sieve of Eratosthenes In PHP

Saturday, July 6, 2013 - 00:07

The sieve of Eratosthenes is named after Eratosthenes of Cyrene who was a Greek mathematician who devised a mechanism to find a sequence of prime numbers using a simple algorithm.

Normally, looping through a list of numbers and finding the primes can be an expensive process. The seive of Eratosthenes is one of the most efficient way of working out all of the smaller prime numbers below (below 10 million or so).

Category: 

Finding The First And Last Items In An Array In PHP

Sunday, March 24, 2013 - 13:41

Getting the first or last item from an array in PHP is usually quite easy. If you create an array and then add a bunch of values to it then the array index will increment by 1 for every element you add. This means that in order to get the first element from an array you just reference the default stating position (0). To get the last item in the array the index key will be the length of the array, minus 1. Here is some example code showing this.

Category: 

APC And Drupal

Sunday, March 17, 2013 - 23:36

Alternative PHP Cache (APC) is an opcode and variable cache for PHP. When you run a PHP script it is first compiled into a series of opcodes which are then used by the Zend engine to run the program before being discarded. APC sits between the source files and the Zend engine and will stop the opcodes generated during the PHP script execution being thrown away. This means that when you run a PHP script a second time the work done in generating the opcodes has already been done and the script will execute faster.

Category: 

Using XPath With HTML Files In PHP

Thursday, March 14, 2013 - 09:53

I recently have started looking into making myself a PHP Zend Certified Engineer and after doing a bit of research I found that the standard PHP string and array functions appear to be a large part of the exam material. So as a starting point (and for future revision) I decided it might be a good idea to create a revision sheet for those functions.

Category: