PHP (23)

Dynamic Object Names – Navigating to method declarations in php storm

One of the things I love about PHPStorm is the way i can navigate to any function or method declaration just by cmd-clicking it (or ctrl-clicking on Windows), except when using dynamic object names. However, there is a problem when you have a dynamically named object. Here I outline the problem, and also the solution, […]

Minify HTML using PHP

Just playing speeding up page, even if it is by milliseconds…! So i decided to minify my static html. preg_replace being as powerful as it is, makes life easy: [code] function minifyHTML($html) { return preg_replace( array(‘/<!–(.*)–>/Uis’, "/[[:blank:]]+/"), array(”, ‘ ‘), str_replace(array("\n", "\r", "\t") , ” , $html) ); } [/code] preg_replace works literally like this: […]

Starting a new project with Cubex framework in PHP Storm

Using PHP Storm to create a new project using the Cubex Framework. In PHP Storm Starting with File > New project. You need to do three things: give the project a name choose a location choose a project type The first two are up to you, for the project type, choose “Composer project”. Next you […]

simple contrast colour in php

I’m just building a website for my small anti-spam verification code, vericode. There are a few configurable options, background colour being one of them, and to make sure the text is still visible, i used the following PHP to do a simple test against “half of white”, and return either black or white text: [code] […]

codeigniter form validation callback

codeigniter form validation callback, when validating forms i need to check something other than just required, or a max length, or any of the default (and very good) built-in filters. i need to check a user login, so need to: define some validation rules (config below), create a callback function, and set a validation message. […]

php session save path permission denied

seems an update in plesk overnight (twice in the last few weeks) has cocked up the php session_save_path: no websites were able to write any sessions, so nothing added to baskets… angry customers… ahem. not sure whether i’m blaming plesk just yet, i’m investigating. but the problem in all error logs is: [code]mod_fcgid: stderr: PHP […]

configure sendmail on mac os x

Unable to send email using PHP mail()? Learn how to configure sendmail on mac os x… Open up /etc/php.ini and set the sendmail_path: [code] sendmail_path = "/usr/sbin/sendmail -t -i" [/code] then restart apache: [code] apachectl restart [/code] if you try sendmail… [code]sendmail[/code] you will get an error: [code] sendmail: fatal: chdir /Library/Server/Mail/Data/spool: No such file […]

CodeIgniter Template the easy way

New to codeigniter template, I’m  just looking at codeigniter (one of many i’m playing with) as a potential framework to adopt, immediately found no built-in way of using a whole html document as a template (unless i’m missing something?) – are there no easy codeIgniter template options? There are loads of codeigniter template extensions and […]

creating html snapshots for google

A recent project required that we use hash navigation for speedy access to content, this also eeded to be indexed well, and seo’d up to the eyeballs, and so i set aboutand creating html snapshots for google. After reading, becoming daunted and almost put off, i realised that its actually a very simple process indeed! […]