php

Make a fully operational REST API in PHP

Routing a JSON REST request
Converting it into SQL
Executing it
Giving a meaningful response

Running
Save this file as “api.php” in your (Apache) document root and call it using:
Or you can use the PHP built-in webserver from the command line using:
The URL when ran in from the command line is:
NB: Don’t forget Read More →

Fotolia_45264356

1. Human Readable Random String
This code will create a human readable string that will look more close to dictionary words, useful for captchas.

/**************
*@length - length of random string (must be a multiple of 2)
**************/
function readable_random_string($length = 6){
$conso=array("b","c","d","f","g","h","j","k","l",
"m","n","p","r","s","t","v","w","x","y","z");
$vocal=array("a","e","i","o","u");
$password="";
srand ((double)microtime()*1000000);
$max = $length/2;
for($i=1; $i<=$max; $i++)
{
$password.=$conso[rand(0,19)];
$password.=$vocal[rand(0,4)];
}
return $password;
}

2. Generate a Random String
If you don’t need human readable string, then use Read More →

rest-websrvices

There is a list at the official PHP website: http://www.php.net/manual/en/refs.webservice.php You can see that PHP can work with OAuth, SCA, SOAP, Yar and XML-RPC. But there is another way which is so simple to create a webservice. It is JSON.
How to create a simple web service with JSON
I will show how to create a simple Read More →

UPDATE: I updated this article with some information about password cracking with the reason to use the algorithms bcrypt or scrypt to store the user’s password instead of hash + salt mechanisms. Moreover, I proposed a new RNG based on the usage of /dev/urandom if OpenSSL is not available.
If you are a professional web developer, Read More →

In this article we’ll explore the Dropbox PHP API by building a simple client for accessing files in a Dropbox account. The client will perform some basic operations, such as :

authentication,
listing files,
uploading
downloading files.

Your starting point for anything related to development with Dropbox should be the Dropbox Developers Center where you can find the API Read More →

http://gearman.org/getting-started/
How many times have you developed a web application that had some functionality which would benefit from running an external program or even forking a separate process? This is not something you generally like to do from your web app because you want to make it run as fast and efficient as possible, while keeping Read More →

Recursive functions can be very useful when developing in PHP.
A recursive function is simply a function that calls itself, but why would you want your function to be able to call itself?
They are best used when a problem needs to be solved by breaking it up into a smaller instance of itself. Examples of this Read More →

References in PHP are a means to access the same variable content by different names.They are not like C pointers; for instance, you cannot perform pointer arithmetic using them, they are not actual memory addresses, and so on. Instead, they are symbol table aliases. Note that in PHP, variable name and variable content
are different, so Read More →

The Model-View-Control (MVC) pattern, originally formulated in the late 1970s, is a software architecture pattern built on the basis of keeping the presentation of data separate from the methods that interact with the data. In theory, a well-developed MVC system should allow a front-end developer and a back-end developer to work on the same system Read More →

I have to admit the first time I peeked at the academic definition of the Open/Closed Principle, its predicate was surprisingly clear to me. Leaving all of the technical jargon out of the picture, of course, its dictate was pretty much the mantra that we’ve heard so many times before: “Don’t hack the core”.
Well, admittedly Read More →

Overview of the WAV Format
The Waveform Audio File Format, also known as WAVE or WAV, is a Microsoft file format standard for storing digital audio data. A WAV file is composed of a set of chunks of different types representing different sections of the audio file. You can envision the format as an HTML page: Read More →

In today’s world with so many third-party integrations and content-sharing, it’s important to understand and make use of protocols like SCP and SFTP. PHP’s SSH2 extension, a wrapper for libssh2 which implements the SSH2 protocol, provides several functions you can use to securely transfer files.
To begin leveraging these functions, it’s obvious the SSH2 package needs Read More →

I've had a couple of emails recently about the excellent Stanford Machine Learning and AI online classes, so I thought I'd put up the odd post or two on some of the techniques they cover, and what they might look like in PHP.
The second lecture of the ML class jumps into a simple, but often Read More →