spacer
Web Development Blog
 Developer Newsletter

Webmaster Blogs
Content & Blogging
Design
Photoshop
General
JavaScript
PHP
PHP Functions
Web
WordPress
Website Promotion

Blog Archives


Developer Tutorials
AJAX
ASP
CGI & Perl
CSS
Flash
HTML
Illustrator
Java
JavaScript
Linux
MySQL
PHP
Photoshop
Python
Wireless
XML
Miscellaneous

Scripts Directory
AJAX Scripts
ASP Scripts
ASP.NET Scripts
CGI & Perl Scripts
Flash Scripts
Java Scripts
JavaScript Scripts
PHP Scripts
Python Scripts
Remotely Hosted Scripts
Tools & Utilities Scripts
XML Scripts

Web Hosting Directory
ASP.NET
Budget
Dedicated Servers
Ecommerce
Linux
Resellers
Shared
Small Business
Windows

Blog Feed

Posts Tagged ‘PHP’

Designing and Coding a Wordpress Theme From Scratch (Part 10)

Wednesday, April 30th, 2008

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…)

Learn regular expressions in PHP

Wednesday, April 30th, 2008

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.

(more…)

Designing and Coding a Wordpress Theme From Scratch (Part 7)

Tuesday, April 29th, 2008

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”


Beginning with PHP for WordPress

  • First we’ll duplicate index.html and rename the copy index.php. We’re only keeping the original .html file for reference to make sure that the finished PHP operates and looks the same.
  • Let’s open index.php in our text editor. Right now it’s just a .html renamed .php. Our job is to make make it true PHP.
  • (more…)

Designing and Coding a Wordpress Theme From Scratch (Part 6)

Tuesday, April 29th, 2008

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”


Marking Up Is Hard To Do

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.

(more…)

Iterating PHP objects, and readable code too!

Tuesday, April 29th, 2008

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.

(more…)

PHP array_walk(): Run an array through a function

Tuesday, April 22nd, 2008

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.

PHP-friendly web services/APIs for quick mashups

Friday, April 4th, 2008

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/web services

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.

Handling API output

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.

Some PHP-friendly APIs

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.

PHP 6 now with .net: Visual Studio integration available already

Tuesday, April 1st, 2008

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:

PHP 6 with .net and Silverlight in Visual Studio

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:

Visual (RAD) development for PHP - .net forms and controls with WinForms

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.

Open Source Social Networking Server: Built on LAMP!

Friday, March 28th, 2008

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.

(more…)

The ultimate PHP web development environment, part 2

Sunday, March 23rd, 2008

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.

(more…)





About the NetVisits, Inc Network | Write For Us | Advertise
Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy.
Visit other NetVisits, Inc. sites: