Tag Archives: php

PHP error_reporting Boolean Values

The PHP page is really not that useful, and only talks about using the PHP Contstants E_ALL, E_NOTICE, E_STRICT etc

This information is not obvious on the PHP site, so I’m just putting it here as an aid to my brain cells. This is for PHP 5.2.x

E_RECOVERABLE_ERROR = 4096
E_USER_NOTICE = 1024
E_USER_WARNING = 512
E_USER_ERROR = 256
E_COMPILE_WARNING = 128
E_COMPILE_ERROR = 64
E_CORE_WARNING = 32
E_CORE_ERROR = 16
E_NOTICE = 8
E_PARSE = 4
E_WARNING = 2
E_ERROR = 1

E_ALL = 6143 = 1011111111111

Therefore E_ALL & ~E_NOTICE = 6143 – 8 = 6135

And to kill warnings as well:

E_ALL & ~E_NOTICE & ~E_WARNING = 6143 – 8- 2 = 6133

WordPress blogroll link order – Change widget behaviour

Another quickie here. Although people use various blogroll plugins, sometimes the standard widget has it’s place (some themes don’t allow custom code to be used in some areas of your blog, for example). The problem is that the standard widget only displays links in alphabetical order based on the link name. There are two ways you can correct this.

1.) Change the default behaviour of the script that produces the blogroll lists

No problem, just go along to /wp-includes/bookmark-template.php – and find the code around line 198 Read More…

Cubecart Error – Warning: htmlentities() expects parameter 2

Just a quick note for those people who upgraded to Cubecart 4.3.9, and started to experience horrible page titles containing things like:

Warning: ¬†htmlentities() expects parameter 2 to be long, string given in /home/user/public_html/admin/sources/products/index.inc.php on line 949 etc…

There is a bug fix published by Cubecart but it isn’t terribly helpful. The problem is indeed on line 949 of /admin/sources/products/index.inc.php which should read (once corrected) as follows:

<td align="left"><input name="prod_metatitle" type="text" size="35" class="textbox" value="<?php if(isset($results[0]['prod_metatitle'])) echo htmlentities($results[0]['prod_metatitle'],ENT_QUOTES,'UTF-8'); ?>" /></td>

Read More…

PHP 301 Redirection – Web forwarding done right

HTTP RedirectionPHP 301 Redirection

Redirection is usually better done via .htaccess files, but in case your hosting provider doesn’t support this method, then you can achieve simple redirection on a per-page basis using PHP. This is the method I am going to discuss in this article.

When to use redirection

Lets’s say you had a page that was quite popular, but it had to move to a different place in your website. It is listed in google, and you don’t want to loose out by the page being unavailable after you delete the old one. Rather than just keeping the old page, and putting a message on it saying “this page has moved” (yuk!) – it would be much nicer if we could tell google (the the rest of the world) that your page has permanently moved. Read More…