PHP alternative, lazy syntax
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:
-
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 »
Passing the Joel test – step 1 setting up a versioning system for Windows
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 »
Introduction into SOAP, setting up a simple webservice with PHP SOAP
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 »
Limit the number of newlines in a string
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 »
Using the Google currency converter
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 »
8 Netbeans tips to speed up development
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 »
IDE roundup, 10 reasons why every PHP developer should try Netbeans
- Eclipse PDT / Aptana with PHP Plugin
- Zend Studio 6
- Zend Studio 7
- Notepad++
- NuSphere PHPED
Using the BitLy API to shorten urls
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 »
Creating XML files with DOM Document
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 »