Monday, August 30, 2004

Getting Started with PHP - Part 1: Installation.

To start learning PHP, you first need PHP running on your computer. If you totally have no idea what PHP is, you might want to read my earlier story: Why I like PHP / MySQL

Assumptions are you are a Windows user(since most Linux distributions have PHP & MySQL included), most probably why you would want to learn this is because you are a: 1) programmer that wants to program for online applications aside from desktop applications only or 2) a web designer that wants to learn programming to also get into web development.

What I am going to discuss, is how to install PHP on a Windows system. And I will tell you three different installation procedures.

1) PHP Manual Installation
2) PHP Windows Installer
3) Other PHP Packaged Installers

PHP has many extensions to the language, which is also one of the reasons why it is one of the most powerful server side programming languages. To enable all available extensions, you will need to manually install PHP that is basically done by extracting files from a compressed downloaded file, placing the files in a certain location, editing windows registry, configuring your web server and configuring the php.ini file.

Since this story is about "getting started," I do not recommend doing this. And most of the additional extensions you may use are not needed by the novice PHP programmer.

Now using the PHP installer is a lot easier, it has all the basic extension enabled already. And installs like any other software, just run setup and it’s all next, next, next.

Although, either manual or automatic, you need your web server software installed and preconfigured prior to your PHP installation, or else PHP will not work.

Windows 98 and ME comes bundled with the Personal Web Server (PWS) and Windows XP and 2000 comes bundled with the Internet Information Server (IIS) that you could add to your computer as long as you have the original Windows Installation CDs.

But being a novice PHP programmer, I highly recommend using other PHP packaged installers. There are several out there when you search sites like SourceForge or FreshMeat and part of the so many results, you'll get PHPTriad and PHPDev. These package installers are simple to install, just run setup. And when your done, you have just installed Apache web server on Windows, PHP and MySQL. And you could use it right away without any configuration whatsoever. I use PHPDev5 Beta and I do suggest you do the same.



You can download PHPDev5 Beta from FirePages, or click here to go straight to the download page.

Once downloaded, simply run the downloaded file, it is pretty straight forward, no confusing questions. And once installed, try running the program and you will see something like this:



Now since you are just starting out, you would only want to click on the Apache button and the MySQL button. You could install both Apache and MySQL as a service, but if you have a slow running computer, I suggest not installing it as a service. But you will have to always run PHPDev and start Apache and MySQL whenever you need to run them. If you have a fast computer, installing them as a service will also keep them running once you turn on your computer.

There is no PHP button since PHP starts to run whenever it is needed and called by Apache. You may also notice an Apache2 button, don’t play around with it yet. It is still kind of an experimental feature, so just use Apache alone.

Now after running PHPDev5, how do you test if apache is working?

Simply open your favorite web browser and visit http://localhost and this should display the files in the apache web root directory. If you get error 404, something is wrong. Be sure that you started Apache already before visiting http://localhost.

If you see files in the apache root web files, simply click on the start_here.htm file and it will give you a brief summary if everything is running and how can you test them further.

Now with PHP successfully installed, how do you start off learning PHP? Well that’s a long story but to get you started, let’s do a simple "Hello World".

So let’s say we are going to create a file that simply says "Hello World" using PHP. Just follow the instructions step by step below:

  1. Create the folder c:\my_first_php_file

  2. Open your favorite HTML editor or simply use Notepad and type in the following:

    <?php
         echo "Hello World<br>";
    ? >


  3. Save this file in the created folder and name it hello.php

  4. Open PHPDev, click on Apache, then Edit Config.

  5. You can actually type this anywhere but I suggest place it somewhere by the end of the text window, so it is easier to find in the future, just go to the end and type this:

    Alias /myfirst "c:/my_first_php_file /"
    <Directory " c:/my_first_php_file /">
         Options Indexes FollowSymLinks MultiViews
         AllowOverride None
         Order allow,deny
         Allow from localhost 127.0.0.1
         DirectoryIndex index.html index.htm index.php
    </Directory>


    Please take note you are typing forward slashes, not back slashes.

  6. Click on the Save button, then Close button. Then back at the Apache options, click on the Restart button.

  7. Now try visting: http://localhost/myfirst/hello.php

  8. That’s it! How boring!

  9. Now try something else, create a new file and type the following:

    <?php
         phpinfo();
    ?>


    Save it and name it index.php. Since it is the index page, this is the first page that will appear when you visit http://localhost/myfirst Check it out and see what happens. PHPInfo will show many details about the PHP configurations on the server. It does help a lot in the future when you start using the other PHP extensions and also when you use some Apache environment variables, and server environment variables, especially when uploading on a new server that you do not know how PHP is configured.
Although PHPDev5 can be used live on the Internet. As long as you know your IP address and is connected to the Internet, anyone can visit your page running Apache even on a dial-up connection. But this is not recommended at all. PHPDev is ideal for testing PHP programs offline on a local web server. And once your program is ready for uploading, you will upload your PHP program to a secure web server.

Now that you have your first PHP program running and you want to learn more, wait for my next articles, in the meantime, I suggest you download the PHP Manual, at PHP.net in the documents section. You could actually download a Windows Help File format and start learning PHP on your own. Anyway that is how I started. I downloaded the MySQL manual too.

Thursday, August 19, 2004

Softwares for Accurate Time and Weather

How is time measured? For many years one second was defined as 1/86,400 of the mean solar day, thus eliminating seasonal variations. So this was based on the movement of the sun, but we all know that it is actually the movement of the earth. And we were assuming the earth moves at a very precise constant rate, which it does not. And the earths rotation is not really 24 hours. It is 23 hours, 56 minutes and 4.09 seconds, that's why the leap year exist.

So given this problem, in 1956 ephemeris time (ET) was used, which is calculated from the motions of celestial bodies in accordance with the laws of motion. 1 sec is 1/31,556,925.9747 of the length of the tropical year for 1900. I can't even imagine how this is done just by looking at the stars around us. But I could imagine a lot of trigonometry and calculus is involved using telescopes in various locations and heights focusing on a single object in space and comparing the angles of the telescopes taking note of the location in three dimensional space of each telescope.

I guess this was too hard to measure that's why in 1967 the second was redefined to be 9,192,631,770 periods of vibration of the radiation emitted at a specific wavelength by an atom of cesium-133. So it this the most accurate? Actually not. Electromagnetic waves could still influence very, very small fractions of the periods of vibration in an atom. Although this is very, very small fractions of a second, as years pass by this will have a great effect.

In Greenwich, London, the Royal Observatory in Greenwich has been transmitting time and called it the GMT standard or Greenwich Mean Time which was used initially to standardize time at train stations throughout Europe. Their time was based on the celestial bodies. Since this was not accurate and the Atomic Clocks were invented, the UTC scale came out of the Coordinated Universal Time. Coordinated since as I explained above the problem with the cesium atom, there are several Atomic Clocks and each one coordinates with each other. I do not know what type of statistics they use, but I assume it is the simple average.

Now one nice thing about the Internet today is that there are Time Servers all over the world that gets updates from these Atomic Clocks, and clocks all over the world could update time from the time servers.

Well let's finish the introduction about time since you might be getting bored already. I used to use a software named Atomic Clock which was recommended by Louie Morales by the way. Then I switched to ClockG2 since it has a world time function. Now I am using WorldTime2000 by MultiSource. But I did not download mine from MultiSource. I got mine from download.com, you could go straight to the link by clicking here. I have had problems with the one downloaded from MultiSource, I do not know why, so I suggest get the one at Download.com too.



Now whenever I am connected to the Internet, I could update my PC clock connecting to the time servers and look at the time at any city around the world. Very useful for me since I am running my business in the Philippines while I am currently in San Diego, California. Now aside from that I could also see the weather at nearly any city around the world. This is powered by Weather.com and they have a software called Desktop Weather. You could download the software here.



Desktop Weather gives you temperature, humidity, UV index, wind speed and direction, atmospheric pressure, temperature highs and lows, sunrise and sunset time and a 12-hour forecast as well as a 3-day forecast. It also has coming storm warnings. So if you like to know what the time and weather is anywhere around the world, I recommend these two softwares.

Wednesday, August 04, 2004

The Informatics Logo



Since most of my audience of this website are from Informatics, this next story is about our logo. Many of us use the logo, but we often get a blurred one, a JPEG or GIF format we got from the web, and when we place it on our printed material, it sometimes, comes out blurry, has jagged edges, has spots all over the white space, or the lines disappear or are not clear.

I always taught in my graphics classes that vector graphics are always clearer than raster graphics when it comes to resizing. And in raster graphic softwares, generally it is best to resize from a large resolution going to a smaller resolution.

Now the best way to always have the Informatics logo as clear as possible is to make a vector graphics version. But with the so many lines, just by looking at the logo, some people do not want to do it anymore. Since you have to re-draw each one in a vector graphics software. And you'll say only crazy people would do that.

Well when I worked in Informatics, I was one crazy person. And in my first month, I already created a vector version of the Informatics logo and whenever I needed it, I had it saved in a CD that I always used.

Now if you need a clear logo of Informatics to be used on any printed material, or on a website, or powerpoint presentation, you could use the formats I made.

But do remember this is not my property, the logo design is still the intellectual property of Informatics, so if you are going to use, do not say it is yours. I just made various versions of the logo free for downloading. I didn't check each one I uploaded, so if ever there is one that got corrupted during the upload, just email me so I could re-upload it again.

Just click on the file format you need below. For the raster formats below, the resolution is 300dpi with a size just right to fit in a 8.5" x 11" letter sized paper. If you do not know what you need, generally for websites and powerpoint presentations, try the .gif and .jpg formats. The common vector graphic versions are .cdr is for CorelDraw, .swf for Flash, .FH10 for FreeHand 10, .ai for Illustrator, .dwg for AutoCAD. I did not upload these versions due to the large file size when maintaining the 300dpi resolution: .eps, .cur, .ico, .xpm, .bmp, .psd, .pp5, .tga, .ppf, .sct, fpx. Although I could make this available if someone requests for it. If ever you downloaded a raster format and it kind of has jagged edges when resizing, try changing the image mode to RGB before resizing since it may be under indexed colors which has less colors for better anti-aliasing.