background preloader

Php

Facebook Twitter

Zend/Doctrine

Doctrine. Zend. Five common PHP design patterns. Editor's note: See the follow-up article "Five more PHP design patterns" to learn about five additional design patterns that you might find useful.

Five common PHP design patterns

Design patterns were introduced to the software community in Design Patterns, by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (colloquially known as the "gang of four"). The core concept behind design patterns, presented in the introduction, was simple. Over their years of developing software, Gamma et al found certain patterns of solid design emerging, just as architects designing houses and buildings can develop templates for where a bathroom should be located or how a kitchen should be configured.

Having those templates, or design patterns, means they can design better buildings more quickly. The same applies to software. Design patterns not only present useful ways for developing robust software faster but also provide a way of encapsulating large ideas in friendly terms. The factory pattern The problem is tight coupling. Ajax Fancy Captcha - jQuery plugin - WebDesignBeach.com. Drag and Drop Captcha Demo What is it: Ajax Fancy Captcha is a jQuery plugin that helps you protect your web pages from bots and spammers.

Ajax Fancy Captcha - jQuery plugin - WebDesignBeach.com

We are introducing you to a new, intuitive way of completing “verify humanity” tasks. In order to do that you are asked to drag and drop specified item into a circle. Captcha’s security level is medium, with the emphasis on nice looking and user friendly qualities while still offering reasonable protection from unwanted “guests”. Update for September 2009: reduced size,easier integration,easy translate,few common problems fixed. File structure: -captcha –imgs –captcha.css –jquery.captcha.js –captcha.php –iepngfix.htc -latest-jquery -latest-jquery-ui -example.html -readme.txt How it works: It calls captcha.php file and gets a random number.

Codeigniter

PHP Tutorials Examples Convert BMP to JPG. <? Php /** * * @convert BMP to GD * * @param string $src * * @param string|bool $dest * * @return bool * */ function bmp2gd ( $src , $dest = false ) { /*** try to open the file for reading ***/ if(! ( $src_f = fopen ( $src , "rb" ))) { return false ; } /*** try to open the destination file for writing ***/ if(! ( $dest_f = fopen ( $dest , "wb" ))) { return false ; } /*** grab the header ***/ $header = unpack ( "vtype/Vsize/v2reserved/Voffset" , fread ( $src_f , 14 )); /*** grab the rest of the image ***/ $info = unpack ( "Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vimportant" , fread ( $src_f , 40 )); /*** extract the header and info into varibles ***/ extract ( $info ); extract ( $header ); /*** check for BMP signature ***/ if( $type !

/*** set the pallete ***/ $palette_size = $offset - 54 ; $ncolor = $palette_size / 4 ; $gd_header = "" ; Debugging PHP with xDebug inside of Eclipse PDT 2.1. Wrapping C++ Classes in a PHP Extension. One of the most common reasons people write extensions for PHP is to link against an external library and make available its API to PHP userspace scripts.

Wrapping C++ Classes in a PHP Extension

Often the external library is written in C or C++. If you are tasked with writing such an extension that links against an object oriented C++ library, you will probably want to wrap the C++ classes and make them available to PHP userspace scripts. This is pretty easy to do once you get over a few initial hurdles. In this tutorial I am going to walk you through creating a PHP extension called “vehicles” which will expose a single class called “Car” (obviously in the real-world, your extensions will expose many classes, but I’m trying to keep things simple). The extension will be built for PHP 5. File Layout The extension you will be creating consists of several files which you should place in a directory called vehicles: Configuring the PHP Build System.

Resizing images with PHP. The following script will easily allow you to resize images using PHP and the GD library.

Resizing images with PHP

If you’re looking to resize uploaded images or easily generate thumbnails give it a try Update: Looking to resize transparent PNG’s and GIF’s? We’ve updated our original code, take a look at Usage Save the code from the ‘the code’ section below as SimpleImage.php and take a look at the following examples of how to use the script. The first example below will load a file named picture.jpg resize it to 250 pixels wide and 400 pixels high and resave it as picture2.jpg If you want to resize to a specifed width but keep the dimensions ratio the same then the script can work out the required height for you, just use the resizeToWidth function. You may wish to scale an image to a specified percentage like the following which will resize the image to 50% of its original width and height You can of course do more than one thing at once.

The code Further Information.

WordPress

Drupal. Référence des fonctions.