Symfony: accessing the request

20/11/2007

The commonly used

$this->getRequestParameter('blah')

is a shortened version of

$this->getRequest()->getRequestParameter('blah')

All sorts of other goodies are available using $this->getRequest(), including for example:

$this->getRequest()->getPathInfo()
No Comments

Case insensitivity in regular expressions

11/10/2007

Use the letter i after the ending delimiter. For example:

preg_match("/^TMG-[A-Z]-([0-9]+)/i",$itemNumber)
No Comments

PHP: sessions that work across subdomains

9/11/2006

The solution is to use session_set_cookie_params() to allow any subdomain to access the session:

session_set_cookie_params (86400,'','.yourdomain.co.uk');
session_start();

Note the dot before the domain name. session_set_cookie_params() must be called before session_start(), and must be called on every request.

No Comments

PHPMyAdmin 2.6.x bug: ISNULL

6/11/2006

The SQL parser in PHPMyAdmin 2.6.x (the version used in Plesk 7.5) falls over when confronted with an ISNULL query, for example:

SELECT ISNULL(id) FROM user

The bug is fixed in recent versions of PMA (2.9.x works fine).

No Comments

PHP: Creating RSS and Atom feeds

24/08/2006

FeedCreator seems to be the best solution out there.

No Comments

Rails: inspecting an object

9/08/2006

Where we’d use print_r in PHP, use the inspect method in Ruby.

@monkey.inspect

When using Rails, you can use the ‘debug’ method instead, which often gives more useful results.

<%= debug(@monkey) %>
No Comments

Smarty: empty cache

8/03/2006
$smarty->clear_all_cache();
No Comments

PHP: output a set number of whole words from a sentence

2/11/2005

Only output a set number of whole words from a sentence:

$result = implode(' ',array_slice(preg_split('/\s/',$row['article']),0,35));
No Comments

Turning off PHP short tags in .htaccess

6/10/2005

If you need to stop PHP parsing short tags (<? without the php), for instance if you want to use an XML prolog in a page, pop this in an .htaccess file:

php_value short_open_tag off
No Comments