Handle REST easily using PHP

Managing a RESTful application in PHP can become a headache if you are new to REST but I have developed a reusable class function that will save you hours of development time shown below.  Feel free to reuse it.

 

Create $variable from $value using PHP

Sometimes you might need to create a variable in PHP having the name of some value.  Below is the easiest way to accomplish this need.

 

PHP Shorthand If/Else Statements

Using PHP shorthand IF/Else statements are a great time saver and help make your code look neater.  Here is a collection of examples I often use.

 

Enforce UTF-8 on JSON export using PHP

When you export JSON form PHPwhich contains data from an “unclean” data source you must enforce UTF-8 upon the data that will be added into your JSON structure.  Below I’ll show an example of exporting JSON and enforcing UTF-8 upon each record data entity.

 

Create and Export XML using PHP

Sometimes you need to export a collection of data for use to another system.  One of the easiest ways is to export it to XML as it is widely accepted as a data exchange format and standard.  PHP makes creating and exporting to XML very easy.  Below I’ll show you an example where I am exporting some jobs from a job board I created.