Sjoerd Maessen blog

PHP and webdevelopment

Author Archive

PHP alternative, lazy syntax

without comments


Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/smaessen/domains/sjoerdmaessen.nl/private_html/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2147

Alternative, lazy what?

Consider the next example:

  1. span class=”st0″>'<li>’‘<a href="/news/’.$oItem->id.‘-‘.$oItem->rewrite.‘.html">’.$oItem->title.‘</a>’‘</li>’

We could write the above like this: Read the rest of this entry »

Written by Sjoerd Maessen

April 12th, 2010 at 7:22 pm

Posted in syntax

Tagged with ,

Passing the Joel test – step 1 setting up a versioning system for Windows

without comments

Until the last PHP conference I attended (the PHP benelux conference 2010) I used an normal Windows XP installation with a Zend Server CE installation on it at home, and yeah it worked. At the office we already used versioning, bug tracking and some other Joel points. I could see the advantages clearly, even if I was developing on my own at home but I just couldn’t find time and motivation to start converting my home server to something more serious. That is until I attended a track on the Joel test of lornajane. (Slides are available here). I thought it would be a nice idea to keep my Windows installation on the server during this adventure to pass the Joel test. Read the rest of this entry »

Written by Sjoerd Maessen

March 20th, 2010 at 10:00 am

Posted in IDE,Server

Tagged with , ,

Introduction into SOAP, setting up a simple webservice with PHP SOAP

with 2 comments

I was asked to create a simple webservice that would allow us to transfer a intranet post to an external CMS. In this post I will explain the steps you must take to set-up a simple webservice with the PHP SOAP extension.

The first step, create a simple class that we will use to request data from
We will create a class with one method that returns a string with the parameter we called it. The method will accept one parameter and will check if the value is correct.
Read the rest of this entry »

Written by Sjoerd Maessen

February 11th, 2010 at 1:26 pm

Posted in SOAP

Tagged with

Limit the number of newlines in a string

without comments

A very short blog post this time. I often use the following short function to limit the number of breaks/newlines in comments that people can submit on a news article or other user input. You can easily limit the number of characters in a comment by using the PHP strlen function, but the comment can still use a lot of vertical space on your website if the user uses 5 breaks in his comment. See the function below to prevent this type of comments:
Read the rest of this entry »

Written by Sjoerd Maessen

January 28th, 2010 at 10:44 pm

Posted in Regexp

Tagged with , , ,

Using the Google currency converter

without comments

For a project I’m working, I needed to get shipping rates from the UPS API (a blog post about this will follow soon).

The problem I ran into was that the UPS API returns the shipping rates with the currency of the country where the rates for are asked, so you can’t force it to always return the rates in EUR.

One solution to convert the prices is to make a very big array with all currency rates in it. I then would maintain the array every day at 9’o clock to check if the rates weren’t changed. Right, that’s not an option.
Read the rest of this entry »

Written by Sjoerd Maessen

January 11th, 2010 at 8:56 pm

Posted in API

Tagged with ,

8 Netbeans tips to speed up development

without comments

Netbeans is a great editor, below some tips to get the best out of it.

Use the shortkey for “Last Edit Location” default: CTRL+Q
Often I’m editing file and browse to another location inside the file. To go back to where I was Last Edit Location is a nice feature, it replaces the use of ctrl-z + ctrl-y to go to the previous location without changing anything. By htting the key multiple times all edit locations will be traveled.
Read the rest of this entry »

Written by Sjoerd Maessen

December 15th, 2009 at 12:58 pm

Posted in IDE

Tagged with ,

IDE roundup, 10 reasons why every PHP developer should try Netbeans

with 7 comments

A few months I have been looking for my ultimate PHP editor and now I finally found one! I’ve worked with a number of IDEs:
  • Eclipse PDT / Aptana with PHP Plugin
  • Zend Studio 6
  • Zend Studio 7
  • Notepad++
  • NuSphere PHPED
All of above editors just couldn’t satisfy my wishes.

Read the rest of this entry »

Written by Sjoerd Maessen

December 8th, 2009 at 6:44 pm

Posted in IDE

Tagged with , , , ,

Using the BitLy API to shorten urls

without comments

I was asked to place Twitter messages with product links when new products were added to a webshop. I’ve used my own Twitter class for posting the first test Tweet then I went looking for a shorten url a service to shorten the product links.

There are many url shorten services available on the internet, one of these services is Bitly.
The reasons why I’ve chosen Bitly:
– Urls don’t expire after a period of time.
– Bitly provides a click url summary (although Google Analytics can be used for this instead)
– Urls are short in length so i could use the remaining Tweet length for a small product description.
– And more important, they provide an easy to use API.
– Authentication does not require a password, we can use our API key instead.
Read the rest of this entry »

Written by Sjoerd Maessen

December 4th, 2009 at 5:05 pm

Posted in API

Tagged with ,

Creating XML files with DOM Document

without comments

As a first blog post I would like to have some attention for the fact that a lot of programmers are using functions and classes for doing exactly the same as what can be accomplished by using default PHP extensions.

XML files are very common nowadays and every developer needs to deal with them one day. Most of the scripts and classes used to generate XML files string use concatenation and echo to buildup XML files. Although this is a very short and quick method for simple XML files the same approach is often used with more complex XML files with namespaces. The code then often becomes bloated, unreadable and slow, so why not use the PHP 5 DOM API instead (or if you travelled from the past and still use PHP 4 try DOM XML). A quick example of the PHP 5 DOM API usage below.
Read the rest of this entry »

Written by Sjoerd Maessen

December 3rd, 2009 at 11:47 pm

Posted in XML