Tag: php

  • CakePHP Global Constants and Functions

    If you ever find yourself perusing some of the default code that comes with CakePHP, you might find yourself somewhat curious and confused when you see such functions as <?php e(‘Hello World’);?> or <?pho echo h(‘<a href=””>Hello World</a>’);?>.

    I know I certainly was and became determined to understand what the heck these were doing.  It quickly became apparent that these were just two of the many built-in extension functions that are part of the CakePHP framework!

    (more…)

  • The Best Way to Prevent SQL Injection

    If you use a framework of some sort, you probably haven’t thought about SQL injection for some time – in fact it almost seems dated to even discuss it.  However, security should never be overlooked and it’s important to not trust third party applications and people by default!  So what is the best way to prevent SQL injection?

    Have you noticed how I haven’t specified a specific language?  This is done purposely, because at the end of the day – all languages – should be able to follow this paradigm…

    (more…)

  • PHP: Require/Include vs Autoloader

    Google has long since ingrained into my brain how important every millisecond is when dealing with large amounts of traffic.

    In this post, I’m going to demonstrate a really simplistic way to improve your PHP website performance.  It seems to go against the grain of “old school” vanilla PHP writing, but the results are incredible!  By removing the use of require and include and replacing it with a spl_autoload_register function instead, the time savings are more than 10 times!

    Not only that, in theory it’s less lines of code!

    (more…)

  • CakePHP Version Comparison with PHP Version Comparison

    I’ve seen a few recent blog articles comparing the new version of PHP 5.4 to its predecessors and I thought I should get involved with this a bit as well.

    To perform this test, I will layout the conditions I have chosen.  I’m trying to keep this as simple as possible.  I currently run a Dell Laptop with Windows 7 on it:

    Windows NT 6.1 build 7601 (Unknown Windows version Business Edition Service Pack 1) i586

    Because I often do a lot of .NET development recently I have PHP running as a CGI under IIS 7.5.

    I then created a very simple .NET application that performs 100 requests of the same web page and tracks the response time.  These lists of response times are sorted and the highest and lowest responses are dropped.  The average is then calculated from this.

    (more…)

  • How to advance our CMS in CakePHP

    At the end of part one, we had a working CMS.  Well, at least it was saving files and they could be displayed to the public.  In today’s article, we are going to further advance our CMS.  We will cover the following items:

    1. fckEditor
    2. Revisions

    (more…)