code

PHP: The Second Bracket Is Optional

14th October 2009

When writing PHP class or function (basically any file containing only PHP code) files you might have learnt to write them something like this:

 

Using Netbeans PHP Code Templates

11th September 2009

Netbeans is a great IDE and with every version lots more features are introduced that make it even better. One thing that I like to use is the code templates, which have been available from version 6.5. Code templates allows you to type a simple command and get a section of code. What commands you can use depend on what version of Netbeans you are using and which programming language you focused on. As a PHP developer I usually download the PHP version, which comes with a set of PHP code templates.

Prevent People Messing Up Your Goolge Analytics

After running coding sites for a couple years there is one little problem that really annoys me, so when I set up #! code I resolved to fix it. The issue arises when you use some JavaScript based analytics software that allows multiple domains to be used, like Google Analytics. There is nothing wrong with analytics software that allows this, and it is potentially useful for tracking all manner of things. However, some web masters might not be that good at running sites and will lift code from your site (analytics and all) in order to implement a single widget on their site.

philipnorton42 Mon, 08/03/2009 - 16:02
Hide And Unhide Code With PHP

If you are selling a system the last thing you want is for people to copy the system and pass it on for free. There are numerous ways to implement parts of the system that will stop this from happening.

By far the easiest is to create a section of code that is hidden, the removal of which will cause the application to fall over. It could even be as simple as a link back to your site so that even if you give you application away for free, you will always have that link present.

philipnorton42 Mon, 04/27/2009 - 09:49

Display JavaScript Source Programatically

23rd March 2009

If you are running a JavaScript example page you can use the following function that will take the last script element on the page and print it out in a code tag. It uses JQuery to do the work, so you will need to include that library before using this function.

Wordpress Post Friendly Code With JavaScript Replace

12th February 2009

I recently talked about adding code to blogs and comments to Wordpress and making sure that certain characters are encoded properly. So to simplify things I thought I would create a little set of regular expressions that takes a sample of code and convert it into a Wordress friendly format. It consists of the following function, which takes the value of a text area called tochange and runs some regular expression replace functions on it.

Adding Code To Wordpress Blogs And Comments

5th February 2009

Wordpress is a pretty neat blogging platform, but it falls over quite spectacularly when trying to write code in posts. I write a lot of code for #! code and so I have understand what needs to be encoded to make code examples work.

For code example on #! code I use the code tag and I encode the following characters.

Introduction To The Phing build.xml File

5th January 2009

By default, Phing will look for a file in the current working directory called build.xml when you run it. This document tells Phing what it will be doing during the build. You can change this by using the -f or the -buildfile property of phing and giving the build file as the parameter. The following code makes phing look for a build file called wibble.xml.

phing -f wibble.xml

Assuming that the project is called myProject, then a minimal buildfile would be look like the following: