background preloader

Php

Facebook Twitter

Session_start() "Node no longer exists" Build a custom search engine with PHP. In the Internet age, people want information packaged like fast food: served instantly, hassle-free, and in bite-size (or is that byte-size?) Morsels. Indeed, to feed the impatient and hungry masses, even the most modest Web site is now expected to serve a diverse menu of fast-fact formats: RSS is your pizza guy, bringing fresh-baked data right to your door.The weblog is your local Chinese take-out, delivering your favorite spicy dish.The forum is the neighborhood potluck (or perhaps more aptly, the food fight scene in "Animal House").And search is like all-you-can-eat night at your local cafeteriaplex: Just fill up your plate with anything your heart desires, time and again, so long as your gullet — and your chair — hold up.

Five common PHP design patterns - Vimperator. 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 - Vimperator

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. Uploading Files with AJAX. I can’t seem to reach the end of the fun stuff you can do with emerging web technologies.

Uploading Files with AJAX

Today, I’m going to show you how to do something that—until the last while—has been almost unprecedented: uploading files via AJAX. Oh, sure, there have been hacks; but if you’re like me, and feel dirty every time you type iframe, you’re going to like this a lot. Join me after the jump! Untitled. Getting started with dates in PHP. The date() function in PHP is powerful and complex.

Getting started with dates in PHP

In this article, we’ll teach you how to get started. PHP is an amazing language. Implementing a Cache System in PHP in PHP. If you’re a PHP developer looking for a guide that teaches you the concepts behind implementing segregated interfaces and how to utilize them, then you have come to the right place.

Implementing a Cache System in PHP in PHP

This series of articles will show you how to define fine-grained contracts for your classes, so that they can perform only the tasks they’re responsible for. In the last installment of this series, I went through the development of a basic registry system, which was capable of using different registry classes to store, retrieve and even dump data. The most engaging aspect of this sample system was that the swappable registry classes implemented a couple of segregated interfaces in order to execute the aforementioned operations.

As with other elements of object-oriented programming, it’s possible to use segregated interfaces in a great variety of scenarios and conditions and, therefore, enjoy the benefits that they provide right out of the box. (CacheableInterface.php) <? Deploy PHP Project From SVN Using Phing. Automatic building with Phing makes deploying to a server nice and easy, and if you are using SVN as your source control system then you can easily deploy directly from your repository to your web server.

Deploy PHP Project From SVN Using Phing

To allow Phing to utilise an SVN server you must first install the VersionControl_SVN pear library. Although this is in alpha release I have used it quite a bit with no issues. Practical php patterns - Invisible to the eye. This post is part of the Practical Php Pattern series.

practical php patterns - Invisible to the eye

The behavioral pattern of the day is the Iterator pattern, which provides an abstraction over a very common process: the iteration over a collection of objects [or scalars] located in an unspecified part of the object graph. The iteration may be performed in very different concrete ways: over an array property, a collection object, an array, even a query result set. In a world of objects, Iterators maintain array-like capabilities as a non invasive facet of objects.

The Client class is often totally decoupled from the actual implementations of objects and refer to an Iterator interface. PHP Advent 2010 / Color for the Holidays. 21st Dec 2010, by Jon Bond-Caron: If part of your job involves debugging or monitoring PHP apps, you’ll most likely have used tail to check for errors in a log file.

PHP Advent 2010 / Color for the Holidays

While practical, it can become tedious to identify certain types of errors or warnings. If, on average, you spend 15 minutes per day searching for problems, those minutes add up to about 91 hours per year — time you could have spent doing more interesting work! This article will look at implementing ptail, a PHP version of tail -f. We’ll introduce the libevent PECL extension to detect file changes and ANSI escape codes to add some color. PECL libevent If you’re unfamiliar with libevent, it is an event notification library used by many open source projects such as Memcached. Why are we not doing a while loop in PHP to check whether the file has been modified? PHP Advent 2010 / Mistrust and Verify. When working on a web app with coworkers or fellow volunteers, few things are more important within the group than trust.

PHP Advent 2010 / Mistrust and Verify

PHP Advent 2010 / The Ghost of Christmas Past. PHP has been around nearly as long as there has been a Web to develop for, but it evolves constantly and is a modern programming language by almost any definition.

PHP Advent 2010 / The Ghost of Christmas Past

Sure, it might not suit hipsters who only enjoy bands when they can say “you probably have not heard of them; they only formed tomorrow,” but it is not your granddad’s programming language. Sadly, web development often also involves SQL, and that is your granddad’s programming language. SQL, and the stored procedure languages you are most likely to encounter, have deliberately not evolved much since the 70s and 80s. When your programming ancestors were hunting saber-toothed tigers and scratching proposed SQL syntax onto cave walls, they had some fundamentally different ideas to those behind scripting languages. PHP Advent 2010 / Thumbnails. Many of us have had the pleasure of building a web application that requires the automated building of thumbnails from images that are uploaded at runtime.

PHP Advent 2010 / Thumbnails

Thumbnails are hardly the stuff of Nobel laureates, but they’re an uncommon enough annoyance that implementing code to produce them seems like a fresh experience each time. The easiest way to produce thumbnails for a site is to use a pre-built library designed for that purpose. There are a few decent libraries for this, including the PHP Thumbnailer Class, which provides dead-simple ways to manipulate images. Whether used as library code, or as a plugin to other software, this type of library will often do even more than produce thumbnails; it may add watermarks and easily enable programmatic rotation of the output image.

Inclued. Graphviz. Use PHP to convert Twitter to RSS. Before jumping into the topic of Twitter, I have something to get off my chest. Although I'm an avid user and fan of Twitter now, when it first came out, I was a bit nonplussed by it. In fact, I may have been a bit hostile. There. I said it. Now let me give you a bit of back story. A Beginner’s Guide to Design Patterns. Ever wondered what design patterns are? In this article, I'll explain why design patterns are important, and will provide some examples, in PHP, of when and why they should be used. Design patterns are optimized, reusable solutions to the programming problems that we encounter every day.

Shell scripts no more! This weekend, I started my server migration, over to Slicehost. It went well, now I’m running on a lean ‘n mean nginx install. As I was moving my Subversion repositories, I was dreading having to move all my shell scripts, which I used to build and deploy some of my applications (outlined in this post). I was thinking there had to be a better way, after all, Ruby has Capistrano, and though it can be used with PHP, I didn’t want to have to install Ruby, etc etc. After some searching (not much), I found Phing, which looked like exactly what I needed. Sweet! 50 Extremely Useful PHP Tools - Smashing Magazine. Advertisement By Jacob Gube PHP is one of the most widely used open-source server-side scripting languages that exist today. Creating a Twitter OAuth Application. Preventing XSS with Content Security Policy. Page 2 - PHP: Building A Simple Password Encrypter.

Wordpress

Dominic Sayers - RFC-compliant email address validator. This is an email address validation service powered by the free PHP function is_email() created by Dominic Sayers. PHP Creating HTML Widgets. In this third part of a series I develop another sample class, which will use the Object Value design pattern to create immutable HTML div objects in a few easy steps. The pattern’s implementation in this case will be a bit more interesting than usual — it will use the PHP built-in type hinting feature to define a method that returns a new div object to client code, while keeping the immutability of the originating object intact. Email Validation PHP Script with JavaScript and User Verification. RFC standards can be found here: ( Additional controls, such as those for verifying the ownership of email, have also been added to the script.

Going instant with PHP, XML, and jQuery.

Drupal

PHP remote debugging with Xdebug and Eclipse PDT. Debugging is an invaluable part of software development. Rfc2616. Introduction to the Foursquare API. Location-based services like Foursquare are all the rage. » PHPUnit Training Course for free Programming the new world: Programming your life and the net, one day at a time. Quick Tip: Loop Through Folders with PHP’s Glob() PHP snippets to interact with Twitter - CatsWhoCode.com. PHP: Adding Behavior to a URL Class. Joomla. PHP: Modeling a URL Class. Using the Digg API with PHP and PEAR. Table Of Contents - Zend Framework Book: Surviving The Deep End.