Part 3 - “Photoshop to XHTML in 24 Hours” Part 4 - “Cleaning Up Your XHTML” Part 5 - “Preloading Images with Javascript and CSS” Part 6 - “Marking Up is Hard to Do” and “The Anatomy of a Wordpress Theme” Part 7 - “Beginning with PHP for Wordpress” Part 8 - “Putting the Press in Wordpress with PHP” Part 9 - “Marking Up Header.php, Footer.php and Sidebar.php”
So far we’ve made a ton of progress with our theme design. We designed it in Photoshop, we converted to XHTML and then we began the somewhat tedious task of adding PHP. Now that we’ve created index.php, header.php, footer.php and sidebar.php, we can move on to creating the rest of the theme.
(more…)
JonGos in General, PHP, Photoshop, WordPress | No Comments »
Love them or hate them, regular expressions are here to stay. When it comes to quickly dealing with large blocks of data, batch processing operations or screen scraping, regular expressions are often the most effective solution. There’s just one problem, though - learning them can be as hard as learning a new language altogether. Here’s how to get off to a flying start.
Akash Mehta in PHP | 1 Comment »
This is the seventh post in series about creating Wordpress themes with your Photoshop designs. You may want to review before we continue….
Part 1 - “Tools For The Task” and “Preparation” Part 2 - “Layout And Structure” and “Designing Wordpress Themes in Photoshop” Part 3 - “Photoshop to XHTML in 24 Hours” Part 4 - “Cleaning Up Your XHTML” Part 5 - “Preloading Images with Javascript and CSS” Part 6 - “Marking Up is Hard to Do” and “The Anatomy of a Wordpress Theme”
JonGos in PHP, PHP Functions, Photoshop, WordPress | No Comments »
This is the sixth post in series about creating Wordpress themes with your Photoshop designs. You may want to review before we continue….
Part 1 - “Tools For The Task” and “Preparation” Part 2 - “Layout And Structure” and “Designing Wordpress Themes in Photoshop” Part 3 - “Photoshop to XHTML in 24 Hours” Part 4 - “Cleaning Up Your XHTML” Part 5 - “Preloading Images with Javascript and CSS”
Wikipedia defines the term markup as a set of annotations to text that describe how it is to be structured, laid out, or formatted. When we say we’re going to ‘mark something up’ it means we’re formatting the document so that it can be read correctly by machines. Hypertext Markup Language (HTML) is the most common form. That can be marked up to Extensible Hyper-text Markup Language (XHTML) and beyond that to PHP to become dynamic.
Now that we’ve got our basic html layout design we can begin the hard work the transition from HTML to PHP.
JonGos in Design, PHP, WordPress | No Comments »
Today I’m going to take a look at object iteration, most commonly found in the Standard PHP Library, and explore using the Iterator interface to simplify looping.
Akash Mehta in PHP | 2 Comments »
If you’ve been developing with PHP for a while, you’ve probably come across this situation in the past:
<?php foreach ($somearray as &$element) { $element = some_function($element); }
It’s a common sight: taking an array and running (well, walking) its elements through a particular function. Luckily, PHP provides a simple yet powerful function to overcome this: array_walk().
Usage Using array walk is simple. It takes two arguments, an array of data and a callback function to pass the array to. It examines the array and calls the callback function with each element of the array, allowing you to run the entire array through the function without extracting the array yourself. Consider this:
<?php function some_function(&$element, $key) { return $element + 1; } // This: foreach ($somearray as $key=>&$element) $element = some_function($element, $key); // becomes this: array_walk($somearray, "some_function");
It’s cleaner, faster and more effective. It also gives your callback function more information than you might usually provide. The callback parameter can be any : “function_name”, array(’Class_name’, ‘method_name’) or even array($object, ‘method_name’) (where $object can be $this as needed).
Syntax The syntax is very simple:
array_walk (array &$array, callback $callback[, mixed $userdata]);
The first parameter is the array that you want to run through the function. The second is the callback - for a function, class method or object method. The third allows you to pass a third parameter to the callback function from within the current context. This can be anything at all, and along with the array element and its key/index, will be passed directly to the function without modification.
For more details, see array_walk() in the PHP manual.
Akash Mehta in PHP Functions | No Comments »
If you want to build a useful app quickly, you can’t go past a mashup. Take data from someone else’s service, come up with a useful way to mix it up and present it to your users in an innovative manner. Even better, as my recent PHP Site Search tutorial showed, you can build a mashup in just a few lines of code. But how do you find useful web services/APIs, and how do you process the data they provide?
Finding APIs and web services is really quite easy. If you regularly use a web application - for example, I’ve often used Twitter - check if the application provides an API (Twitter has quite a comprehensive one). Next, if you’re looking for data on a particular topic, try searching for it. A quick search for “map api” returns all kinds of useful results. Finally, if you just want to take a look at the internet’s available APIs, head to Programmable Web; they have by far the most comprehensive database available, and it’s fully searchable.
The easiest way is a really PHP-friendly APIs that provides serialized PHP. You can just fetch the URL with file_get_contents(), and run the output through unserialize(); in two lines of code, you have your data ready to work with.
However, most APIs won’t offer serialized PHP output; some might offer JSON, or JavaScript Object Notation, which is somewhat like PHP’s serialized data (although JSON is integrated in the JavaScript language). Others offer XML gateways, while some even provide SOAP, a (rather complicated) means for computers to talk to each other natively. You really have three options:
1. Interpret the output of the API or web service with a PHP-based parser, such as an XML parser (which you can easily find on phpclasses.org) or a SOAP client (try nusoap). 2. Use PHP sample code provided by the API/web service owner - e.g. this Google Checkout PHP sample. Some even provide PECl extensions. 3. Use a third-party library to access the service. For example, people have written PHP classes that allow you to interact with the Flickr API. PHP Classes.org has hundreds of these, and others are just a web search away.
Of course, if you just want to get started right now and quickly add some functionality to your application, try these:
Have a look through these APIs and you could be building a mashup quickly in no time.
Akash Mehta in PHP | No Comments »
Edit: This was partly an April Fool’s joke, as many PHP scripters would be incredulous at the mere idea of PHP integration with Microsoft products. However, as you might have noticed, much of this post is very much real - besides the compulsory .net with PHP 6, of course. The Phalanger project has made done some fantastic work on compiling PHP with .net/Mono, and is definitely worth a look.
When it comes to the enterprise software development market, Microsoft pretty much has it cornered. After all, who else can boast of a complete software ecosystem, fully supported by the company behind one of the world’s wealthiest men? From Visual Studio to the various certifications, VB being taught in schools and even the wide penetration of the Visual Studio family of development environments, MS has pretty much got it in one. But it’s .net that seals the deal: the cross-language runtime environment is perfect.
PHP, .net and Silverlight will be integrated out of the box, along with Visual Studio 2008. The project has long been in the works, but our sources have informed us of an impending announcement that PHP 6 will ship with .net. (Our sources are unreliable, but their information is fascinating! - Ashleigh Brilliant.) Versions 1.0, 2.0 or 3.5 of the .net framework will be a part of the basic requirements of PHP 6 as a result. Here’s a sample:
The .net integration was made possible by the Phalanger project, which has been working hard on this for quite a while - with the help of Redmond, of course.
The Visual Studio IDE typically ships as an IDE with a particular language, merging together when additional languages are added. Microsoft has since released Visual Studio 2008 Shell, an IDE with no particular language environment, in which PHP/Phalanger can be added. Debugging of .net and Silverlight is possible thanks to the integration of Visual Studio. Once installed, a new PHP project will be available from within Visual Studio 2008. WinBinder now has competition for Windows RAD PHP development:
Sysadmins with Windows servers running applications that conflict with the .net CLR are advised to upgrade to the Intercal interpreter once PHP 5 support is dropped.
Social networking just keeps on growing. It seems every major public business wants a Facebook application, corporations are adding social features to their websites, and organisations are bringing social networking into their intranets. Previously, building your own social networking applications involved some serious engineering challenges. Thanks to Ringside Networks, that just got a lot easier, with an open source (LGPL) social networking server built entirely on LAMP.
Akash Mehta in Web | No Comments »
In part 1 of this series, I looked at the web browsers and (Windows) IDEs. Today I’m going to look at a local development server and its PHP configuration, as well as some of the IDEs/editors available for Linux, especially the cross-platform options.
Akash Mehta in PHP | 4 Comments »