Mar 2008
26
07:34pm

I realized that a lot of people who want to learn PHP are having hard time getting started with it - not because PHP is difficult to use or understand but simply because they don’t know where to start. Because of this, I decided to write this short how-to on getting started with PHP. It covers all the necessary stuff to setup Apache, PHP, and MySQL as well as to install one of my favorite PHP editors.

Without further ado, let’s go on…

The simplest way to install everything you need to run PHP web pages on your workstation is to install XAMPP. The beauty of using XAMPP is that it can be installed on any of the following operating systems:
XAMPP Logo

  • Microsoft Windows
  • Linux
  • Sun Solaris
  • Mac OS X

As for XAMPP, it means:

  • X - any of the four operating systems above
  • A - Apache (the web server that serves your PHP web pages)
  • M - MySQL (the SQL database)
  • P - PHP
  • P - Perl

It used to be called LAMPP where L stands for Linux but they decided to change L with X since it’s not just Linux anymore. So how do we install it? Simple, go to http://www.apachefriends.org/en/xampp.html and download the correct installer for your system. To make it even easier for you, I’m including the links to the installer download pages here.

To install, just download and follow installation instructions. (C’mon, you don’t expect me to spoon-feed you everything right?)

After you’ve installed XAMPP, all you need to do is run it. In Windows, all you have to do is run XAMPP Control and start each service that you want. Basically, you’ll want to start Apache and MySQL. After you’ve started Apache, you can now give it a try by browsing to http://localhost/. That should show you the XAMPP welcome page.

XAMPP Control Panel
The XAMPP Control Panel

XAMPP Start Page
XAMPP Start Page (http://localhost/)

XAMPP also comes with phpMyAdmin which allows you to manage your MySQL databases via browser interface. You may access phpMyAdmin by browsing to http://localhost/phpmyadmin

phpMyAdmin
phpMyAdmin (http://localhost/phpmyadmin)

So where do you put your PHP pages so that they are properly served by Apache? With XAMPP, it goes in the htdocs folder of your XAMPP installation. I recommend that you create separate folders for your projects so you can easily manage them.

Now that you have Apache/PHP and MySQL running through XAMPP, the next thing for you to do is install an editor. Any plain text editor such as Notepad will do. However, there are better editors out there that provide syntax highlighting and debugging functions. One of my favorites is Eclipse PDT (PHP Development Tools). It runs on Java which means it is cross-platform.

Eclipse PDT Splash Screen
Eclipse Splash Screen

The easiest way to install Eclipse PDT is to follow these simple steps:

  1. Go to http://download.eclipse.org/tools/pdt/downloads/
  2. Click the Release Build
  3. Download the All-in-One package for your operating system
  4. Uncompress the downloaded package and run Eclipse from there

If you did it correctly, then you should see Eclipse’s IDE. Mine looks something like this:

Eclipse PDT Intergrated Development Environment
Eclipse PDT Integrated Development Environment

One nice feature I like with Eclipse PDT is that it has a list of all the functions supported by PHP making it easier for me to write thousands of lines of code. Also, since it’s an IDE, it also keeps track of your variables, functions, and classes.

Quick but important note, it’s also best to keep a copy of the PHP manual accessible. If you’re always online, then the manual is just a click away. Typing php.net/str_replace on your browser will take you to the documentation of the PHP’s str_replace function. You may also want to download a copy of the PHP manual if you’re not connected to the internet all the time.

There you go. If you’ve successfully installed XAMPP and Eclipse then you already have the basic needs in getting started with PHP.


Share this Post through Social Bookmarking These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • Technorati
  • YahooMyWeb
Mar 2008
22
09:55am

As promised, here’s a sample implementation of the Google Translate API.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Google Translate</title>
<script language="javascript" src="http://www.google.com/jsapi"></script>
<script language="javascript">
 google.load ("language", "1");
 function gtrans (f) {
  document.getElementById("translation").innerHTML = "-";
  var lang = f.langpair.value.split("|");
  google.language.translate (f.translate.value, lang[0], lang[1], function (result) {
   if (!result.error) {
    var container = document.getElementById("translation").innerHTML = result.translation;
   }
  });
  return false;
 }
</script>
</head>
<body>
<form onsubmit="return false">
 <p>Enter text to translate and click "Translate"</p>
 <textarea name="translate" cols="50" rows="5"></textarea>
 <br />
 <select name="langpair">
  <option value="ar|en">Arabic to English</option>
  <option value="zh|en">Chinese to English</option>
  <option value="zh-CN|zh-TW">Chinese (Simplified to Traditional)</option>
  <option value="zh-TW|zh-CN">Chinese (Traditional to Simplified)</option>
  <option value="nl|en">Dutch to English</option>
  <option value="en|ar">English to Arabic</option>
  <option value="en|zh-CN">English to Chinese (Simplified)</option>
  <option value="en|zh-TW">English to Chinese (Traditional)</option>
  <option value="en|nl">English to Dutch</option>
  <option value="en|fr">English to French</option>
  <option value="en|de">English to German</option>
  <option value="en|el">English to Greek</option>
  <option value="en|it">English to Italian</option>
  <option value="en|ja">English to Japanese</option>
  <option value="en|ko">English to Korean</option>
  <option value="en|pt">English to Portuguese</option>
  <option value="en|ru">English to Russian</option>
  <option value="en|es">English to Spanish</option>
  <option value="fr|en">French to English</option>
  <option value="fr|de">French to German</option>
  <option value="de|en">German to English</option>
  <option value="de|fr">German to French</option>
  <option value="el|en">Greek to English</option>
  <option value="it|en">Italian to English</option>
  <option value="ja|en">Japanese to English</option>
  <option value="ko|en">Korean to English</option>
  <option value="pt|en">Portuguese to English</option>
  <option value="ru|en">Russian to English</option>
  <option value="es|en">Spanish to English</option>
 </select>
 <input type="button" value="Translate" onclick="gtrans(this.form)" />
 <p id="translation" style="border:1px solid #00f;padding:5px;width:400px">-</p>
</form>
</body>
</html>

Read the rest of this entry »

Share this Post through Social Bookmarking These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • Technorati
  • YahooMyWeb
Mar 2008
21
10:41am

If you need to translate your website from one language to another then I have some good news for you. Google Translate has released a JavaScript based API that’s both easy to use and implement. It can handle 13 different languages and as much as 29 language pairs.

Read the rest of this entry »

Share this Post through Social Bookmarking These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • Technorati
  • YahooMyWeb
Mar 2008
17
09:13pm

Form input validation is sometimes an annoying part in web development but it’s something that we web developers can’t avoid. In order to make sure that the data being entered by our users are valid, we simply have to validate. Another good use of validation is to provide feedback to the user on whether what they are typing is acceptable or not.

Read the rest of this entry »

Share this Post through Social Bookmarking These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • Technorati
  • YahooMyWeb

AJAX Introduction

Posted by Mike Lopez under Javascript/AJAX
2 Comments
Mar 2008
17
08:25pm

Ever wondered what AJAX is? AJAX stands for Asynchronous JavaScript and XML. It is not a programming language in itself but rather a combination of different web development techniques. Furthermore, AJAX technology is not new though it has only been popularized recently especially by Google (Google Maps, GMail, Google Calendar, etc.)

Read the rest of this entry »

Share this Post through Social Bookmarking These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Stormy Skies Wordpress Theme

Posted by Mike Lopez under Blog
2 Comments
Mar 2008
15
01:53pm

Download: Stormy Skies Wordpress Theme Package.

Finally, a new and appropriate theme for this blog. Introducing the Stormy Skies Wordpress theme. It’s designed for 1024×768 screens and supports widgets. The screenshot below shows the original look of the theme, with no graphics in the header.

Read the rest of this entry »

Share this Post through Social Bookmarking These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • Technorati
  • YahooMyWeb

CSS Dropdown Menu

Posted by Mike Lopez under HTML/XHTML and CSS
1 Comment
Mar 2008
13
02:22pm

Ever wondered how to make those drop-down menus using CSS? There are many ways to do it but they are all pretty similar. Here’s how I do it.

The CSS Code

Read the rest of this entry »

Share this Post through Social Bookmarking These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • Technorati
  • YahooMyWeb
Mar 2008
12
09:10pm

Here’s a nifty little script I use to validate date input with PHP. This function can accept any common date entry and return true if the date is valid or false otherwise.

The Script
<?php

Read the rest of this entry »

Share this Post through Social Bookmarking These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Welcome to Coders Cult

Posted by Mike Lopez under Blog
1 Comment
Mar 2008
10
07:08am

Whew!  Finally, I managed to spare the time and gather the energy required to start off a new website - one that has been in my mind for a very long time already.  Dear friend, allow me to offer you a warm welcome to this brand new website called Coders Cult.

Read the rest of this entry »

Share this Post through Social Bookmarking These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • Technorati
  • YahooMyWeb