作者: 金沙澳门官网  发布:2019-10-01

Native Language Support
PHP is a great language for developing dynamic web sites. Some do it for fun while others for business. It is true that a great part of the web is in English. However, if you are targeting a worldwide audience, then neither English nor Esperanto alone is an option.
If you need to deliver content in several languages, it is a good idea to explore several alternatives. However, some alternatives may not be suitable for dynamic websites. Added to that, there is the overhead of time spent in maintenance. To further complicate things, your needs may not be totally in line with the resources you have at your disposal. Therefore, it is advisable to choose an alternative that suits you best.
I found myself in positions which required me to deliver content in both English and Spanish, and in one project a third language. Here are the possibilities I explored:
Explicit links for each language
Use Apache's mod_negotiation
Use GNU Gettext support in PHP
Write your own
This article gives a brief introduction to the first three possibilities, but then we will go about the fourth solution which suited the requirements best, given the set of constraints. I am assuming that the reader is at least familiar with PHP programming and the use of PHP classes.
Principles of content negotiation
Before we go into exploring the various options, we should understand the basics of content negotiation and how that applies to the development framework. Then, you will be able to develop a web application that can deliver its content in the language of choice of your visitor.
By simply configuring the web browser, the user can set it up in a way that his or her preferred language is used when available. Several languages can be specified in a prioritized list, by setting up the preferences or option of the browser.
ands this list of preferred languages on every request made to the site. This action is totally transparent to the user, as the information gets sent in the Accept-Language header, for example:

Building websites and web applications today is not only about being a great programmer, it’s even more important to be a smart programmer. This means to re-use existing code and applications when possible instead of re-inventing the wheel.

Open source has been around for ages andmuch of the web is built using it. Every developer knows about Linux, Apache, MySQL and PHP (LAMP).

But what about all the other open source projects out there? As a web developer you can save lots of time or optimize the performance of your applications by using many of the other projects that are available.

Lets take a look on what’s out there, free for everyone to use.

New databases on the block

Traditionally you might have been using MySQL. Although MySQL still is a great database many new alternatives has shown up trying to solve some of the issues MySQL has.


MongoDB is one of the new so-called “NoSQL” databases. It’s scalable and offers high performance.

Apache Cassandra

Apache Cassandra is similar to MongoDB in that it’s a “NoSQL” database, which is scalable, and offers high performance. It works well with very large and active data sets.


There are lots of more alternatives out there to choose from depending on your needs. Take a look at this list in Wikipedia.

Cache your data

As some data is used frequently it makes sense to put it in memory instead of querying a database each time. This can speed up a web application greatly.


Memcached is a simple but powerful way to cache small chunks of data in memory.


Redis can be used in the same way as Memcached but also includes many more features. For example it can also store data that should be persistent on disk.

Speeding up web requests

Most websites use the Apache web server to serve pages. This works great for most sites, but as soon as you start to get lots of traffic you might want to optimize things a bit.


Nginx is a web server, much like Apache, but it’s extremely fast. It’s often used to serve static content such as images or as a load balancer.


Varnish is a cache that you put in front of your regular web server. It works by putting all your popular content in memory and serves it directly, instead of having to pass everything on to your web server.

Manage your content easily

If you’re building a website which will have content that will be added and edited by writers you want to have a content management system (CMS). A CMS makes it easy to manage blogs and websites and also offers lots of plugins that can extend the functionality of your site.


While WordPress is a blogging platform it can also be used to manage whole websites, big and small.


Drupal is a complete platform that can be used to build scalable and flexible websites.


There are lots of Content Management Systems available. See thishuge list at Wikipedia.

Having an interactive web user interface

Today you can build a web application that works in many ways just as a desktop application using techniques such as JavaScript and AJAX. Using JavaScript frameworks it has become really easy to build great web applications.


JQuery is a framework with plugins to help build dynamic websites with AJAX interaction and animations.


MooTools is just like jQuery a framework to help build powerful web applications using JavaScript.


If you want to try any of the other alternatives look through thelist in this Wikipedia entry.

Other cool stuff

When you start to build complex web applications there are lots of software, libraries and modules that can help you solve problems that would otherwise take a lot of time. Below are two examples just to get you started.


Node.js is an event-driven I/O framework where you write applications in JavaScript that runs on the V8 JavaScript engine. It’s a great way to build fast and scalable network programs.


RabbitMQ is a reliable and scalable messaging system that can handle high throughput. If you need to exchange data between systems or applications a messaging system is a great way to do this with lots of benefits compared to a custom solution or storing the data in a database.

Use a framework to speed up development

Whether you are using PHP or another language there are several different frameworks available that can help you speed up development and make your code easier to manage.


Symfony is a PHP framework that includes components and tools to help you build complex web applications faster. It also has over 1,000 plugins contributed by the community.

Ruby on Rails

For fans of the Ruby language, Ruby on Rails is the most popular framework available.


Django is a Python web framework developed to help you build high-performing and elegant web applications quickly.


See this list on Wikipedia for a more complete list ofweb application frameworks available for different languages.

Spend your time wisely

As a developer it’s always worth the time to keep up to date on what new software is available as it can help you solve complex tasks easily.

Often time spent planning and doing research at the start of a project is well worth it since you can identify upcoming issues and how to solve them in the best way.

The days where you program your way out of every issue are over, it’s more about using existing technology in smart ways.

There are of course a bunch of other software out there that we didn’t include. Let us know in the comments if there is anything you think is missing.