![]() |
|
|
Published: Saturday, January 06, 2001 By Nathan Pond
Over 4 years ago I set out to learn how I could build a web page. Within months I had immersed myself into the world of ASP and databases. It was all so cool... I wanted to use it on my personal web site. Well, to say the least, things didn't work out like I had planned. (For a list of free ASP Web hosting sites, check out: Finding an ASP Home on the Web!) I tried a number of free ASP hosting places, very few offered databases and the ones that did were a joke. Getting a real host was just too expensive, I'm a college student, I can't afford an expensive hosting package. One day I stumbled onto a hosting site that gave me server side scripting, a database, cgi-bin, and basically everything I need for just $6 a month. The only problem was that it was UNIX, and the server side scripting could only be PHP or htmlscript, neither of which I knew. I went ahead and got the hosting package, and set out to learn PHP. This article will entail some of the key differences between ASP and PHP, and will hopefully make the conversion process a little easier for ASP developers ready to venture into PHP. For starters, PHP is very well documented on the php.net web site (http://www.php.net/docs.php). One key difference I noticed was the built in functionality. As I'm sure most of you know, to do just about anything in ASP you need to create an instance of an object. This isn't the case in PHP. There are built-in functions for e-mail, file manipulation, dns lookups, images, and just about everything else you can think of. Tasks such as e-mail sending can actually be done with one line of code. But before I talk PHP up too much, it should be known that I was upset with one major weakness. Version 3 of PHP had no session support. This has been added in version 4 of PHP, but not all hosts have made the upgrade yet, so be careful to look for that if sessions are important to you. I ended up just writing my own session routines.
One thing that always came back to nip me in the butt was forgetting
to end each line with a semi-colon ( Commenting - There have been numerous times when I have wanted to comment out a block of code. In ASP I had to insert and apostrophe at the beginning of each line. PHP uses the same methods as c++. Here's an example:
Another huge difference is that in PHP all variables are used with
a dollar sign (
Case sensetivity - Now before you get too scared, let me
explain. Variable names are case sensitive.
and
are the same thing.
The equals sign - In VBScript, and Visual Basic, the equals
sign (
However, when you are using conditionals (
Kind of on a related note, inequalities are tested with
Connecting Strings - Strings are concatenated in PHP by the dot
Function return values - In VBScript, to return the value of a function you simply set the function name to the value you want to return. Like this:
However, in PHP you use the
Of course, there are many more differences, but this will get you started. If I had known these points when I was learning PHP it would have saved me a lot of late nights. Happy programming!
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||