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 tips’

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.

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

5 PEAR gems: free php scripts that will help you code quicker

Wednesday, March 19th, 2008

PEAR, the PHP Extension and Application Repository, contains hundreds of freely available packages that can be reused in your application. Packages usually come with various functionality within one or more classes, and the PEAR coding standards make sure packages follow the same general style for ease of implementation. Best of all; they’re all entirely open source, from MIT to GPL.

However, many of these packages are bloated, slow and full of specialised features that you may never want to use. Sifting through the repository is also a challenge; a basic category system is in place, but it’s hard to tell what you want when you don’t know what’s available. Here are some gems from the PEAR repository that you could really find useful.
(more…)

PHP Script execution time and maximum workaround

Saturday, March 15th, 2008

Ever wondered how long your PHP scripts were taking to execute? Or maybe you’ve broken the maximum execution time limit on your server, as defined in your php.ini’s max_execution_time directive. Well, dealing with PHP script execution time is actually quite easy. In this mini tutorial, I’ll show you how to measure your PHP script execution time, include monitoring at different stages of the process, and work around your max execution time limit.
(more…)

7 websites that will make you a better PHP developer

Saturday, March 15th, 2008

Developing in PHP isn’t a textbook science. There’s skill to it, and that skill comes from experience. Now, you could try your hand at every single PHP development challenge out there, or you could learn from the experiences of others, widely published on the web in blogs and developer portals. Here are seven websites you should visit frequently to become a better PHP developer.

(more…)

Extracting text from Word Documents via PHP and COM

Friday, March 14th, 2008

I was recently working on an enterprise project in which I needed to detect the text inside a Word Document. Now, I could have got rid of all the non-standard characters from the .doc file and hoped I got something reasonable at the end. I could have tried to run Word 2007 via command line to save the file as a .docx. Or I could just talk to any copy of MS Word via COM and have it do all the dirty work for me.

Naturally, I chose the latter. Here’s ten lines of code that do just that.

(more…)

The ultimate PHP web development environment, part 1

Thursday, March 13th, 2008

UPDATE: Part 2 now available.

After you’ve been coding PHP for a while, you start to work out what the tools of the trade are, which applications can help you work more effectively, and essentially how to get things done. While developing, your environment is crucial: not having the right tools to do your job can be a serious impediment on productivity. In this new series, I’ll help you bring together the ultimate PHP web development environment.
(more…)

Give Your Visitors a Relative Time

Friday, March 7th, 2008

Toby Somerville recently blogged about giving visitors a rough time - instead of displaying exact timestamps, providing a rough written approximation of the time.

Toby suggested that we generally communicate in approximate times, but on the web we usually work with exact timestamps. His idea was that by displaying the time as you would describe it verbally, he could better communicate the time in a visitor-friendly way.

After reading his post, I understood the merits of the approach, but it struck me that a relative time might be a little more useful for many situations. For example, in a fast moving discussion, a short timestamp (e.g. 8:30 AM) as well as a verbal summary of how long ago the time was (e.g. “4 hours ago”, “20 minutes ago”) are most useful to the user. In fact, this is precisely what Gmail does:

Gmail timestamps

A common feature of Gmail’s timestamp system is approximation, similar to what Toby was getting at. For example, as you approach 60 minutes in the hour, Gmail seems to switch from “x minutes ago” to “1 hour ago”, even if you’re not quite there.

Now, I figured this could be achieved very easily in PHP - and it could. After the jump, here’s the code:

(more…)

Say hello to namespace naming conventions!

Saturday, March 1st, 2008

First, we had variable naming conventions. Then we got classes and functions / methods, so we got general naming conventions. With PHP 5.3 introducing namespaces, it’s time to say hello to namespace naming conventions.

Namespaces were introduced to solve the problem of naming clashes. Once upon a time, all your code lived in one, two, maybe three files, and you could see and know exactly what was going on. Then applications started expanding, and OOP came along. Suddenly there were hundreds of functions, classes and methods in your application, not to mention variables and properties.

(more…)

Zend Framework: The Best Framework for Use With Other Frameworks

Wednesday, February 27th, 2008

Here’s an interesting sales pitch. Using a PHP Framework? Cool. Just make sure you add Zend.

The Zend Framework is a fairly standard, (optionally) MVC PHP application framework. It comes with all the usual functionality; request routing, database access, templates (through view files) etc. It also comes with a lot of extra functionality that you might find useful in your application, including some of the best web services libraries available, especially when working with Google’s APIs.

(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: