Tag Archives: php

Stop Category Pages From Showing No Results Message

WordPress Development 3 Comments

If you have a category page which has no posts, it will normally trigger your theme’s no posts found message. Seems sensible! However, I have an edge case where I don’t want that message displayed.
Continue reading

Setting Cookies In WordPress – Trap For Beginners

| Created: September 26th, 2008
WordPress Development 52 Comments

I recently wrote about displaying ads only to search visitors in WordPress. A key part of the technique described is to set a cookie, identifying the visitor as having come from a search engine. It should have been simple, but my PHP setcookie command didn’t appear to work. Continue reading

NetBeans IDE 6.5 Beta for PHP Developers

| Created: August 18th, 2008
PHP Development 31 Comments

In one of my older posts, on PHP Performance Profiling with APD, there’s a discussion in the comments about which IDE is best to use with PHP. Terence Chang recommends Zend Studio and mentions Eclipse. Dreamweaver’s also discussed and I state that I just use a text editor (with syntax highlighting).

Against that backdrop, I read with interest that the NetBeans IDE 6.5 Beta has just been released and that it now caters to PHP developers (article by Lloyd Dunn). Continue reading

Creating A JavaScript Array Dynamically Via PHP

| Created: March 20th, 2008
PHP Development 16 Comments
Update – 1 August 2013:
There are lots of suggestions in the comments that are better than my original solution. Also, with 5 years of hindsight, I’d approach it differently anyway! The way I’d do this now would be as follows:
[sourcecode language=”php”]
<script type="text/javascript">
var lcValues = <?php echo json_encode($myPHPArray); ?>;
</script>
[/sourcecode]
So much simpler! PHP4 has almost disappeared so there’s no reason not to use json_encode. I’d recommend that you stop reading now and just go with that.

If you use PHP to create web pages, there may be times when you need to create a JavaScript array dynamically from a PHP array. This is not hard to do, but there is a trap you need to be careful of: dealing with arrays containing only a single element. Continue reading

PHP Performance Profiling With APD On Windows

| Created: December 27th, 2007
Web Page Optimisation 26 Comments

When writing code, its important to keep system performance in mind. No matter how useful your software is, if it places too much stress on the server, it won’t be used. How can you tell if your code is efficient? Well, experience helps, but it also pays to have good tools. Continue reading