Archive

Archive for September, 2007

Setting up Virtual Hosting in Apache on Windows

September 29th, 2007 Comments off

Setting up Virtual Hosting is easier than you think. You can ignore this step if you want to develop your applications using the http://localhost notation. But in a real case scenario you would like to setup a development environment on your machine to simulate real world conditions.

This tutorial will guide you through the step by step process of how to setup virtual hosting in Apache on Windows. For this example I will be configuring http://dev.sunilb.com as the domain for development purposes. For those of you who don’t have their own domain and/or website to configure, I recommend you seeking advice from a website hosting guide

Read more…

Categories: Apache Tutorials Tags:

How to configure PHP on Apache Windows

September 29th, 2007 Comments off

If you have a stable installation of Apache, then installing PHP is very simple. Read the post on How to Install Apache on Windows if you wish to start with installing Apache first.

Lets begin the configuration.

Step 1: Download the Package

Visit http://www.php.net and download the latest stable release version of PHP which is PHP 5.2.4 as of this writing.

You should download the PHP 5.2.4 zip package.

Step 2: Extract the package

Extract the package to a folder on your drive. I work with C:\php5 and am going to use that as the PHP install folder for this tutorial.

Read more…

Categories: PHP Tutorials Tags:

How to install Apache on Windows

September 29th, 2007 2 comments

So you are interested in working with Apache.

Step 1: Download the package

The first step is to download the package from http://httpd.apache.org/

You should get the latest stable version of the package which is 2.2.6 to the time of this writing. You should download the Microsoft Installer (.msi) package.

Once the package has been downloaded, double click on the icon to run the installation wizard. Click next until you see the Server Information window. Enter localhost for both Network Domain and Server Name. Enter any email that you want for Administrator’s email address.

install-apache-1.png

 

 

Click the Next button and choose Typical installation. Click Next one more time and choose where you want to install Apache. It typically gets installed at C:\Program Files\Apache Group location. Click the Next button and then the Install button to complete the installation process.

Step 2: Verify your Installation

After your installation has been successful, you must open your browser and verify that your installation was indeed successful. Open your browser and type http://localhost. You should get a screen like the one mentioned below:

install-apache-2.jpg

 

By default Apache is configured to read PHP and HTML files from the htdocs folder available under C:\Program Files\Apache Group\Apache2. The location from where PHP and HTML files are stored is called DocumentRoot.

I would recommend that you create a separate folder for your projects and create a virtual hosting for each project to simulate real environment behavior. I follow this principle for my projects/testing. I have a folder by the name C:\sunilbhatia\websites, under which I create sub-folders for each project that I want to execute/develop. Though not a mandate, but you could follow this procedure.

For the time being lets assume that we will be developing our applications under the htdocs folder. In my next article, I will be taking about how to setup virtual domains on your machine.


Notes on Apache Configuration File

Apache stores all configuration details in a file named httpd.conf file. This file is located under the conf folder of the Apache Root folder. Assuming that you installed Apache in C:\Program Files\Apache Group\Apache2 (which is the Apache Root Folder), then the httpd.conf file will be located under C:\Program Files\Apache Group\Apache2\conf\The configuration file for Apache is stored in C:\Program Files\Apache Group\Apache2\conf folder.

Whenever, you change the httpd.conf file you must restart the Apache Server for the changes to be reflected like this: Start > Programs > Apache HTTP Server 2.2.6 > Control Apache Server > Restart

A note of caution, always remember to take a backup of your httpd.conf file before making any changes to it.

You are done with the installation of the Apache Server. Congratulations!!!

After few years, IT persons will face problem without having certified professional status. No doubt that the new coming time is dedicated for 70-631 TS: Microsoft SharePoint Services 3.0 and MCITP 70-443 and 156-315 Check Point Security Administration NGX certified professionals. You should also try to pass the latest Cisco 642-383 CXFF and Cisco DCNS 646-976 Data Center Network Solutions Sales exam.

Categories: Apache Tutorials Tags:

Tutorial 1 – Introduction to PHP Web Programming

September 29th, 2007 1 comment

Welcome to the first chapter of the tutorial on PHP Web Programming.

In this tutorial we will cover the following:

  • About PHP5 Scripting Language
  • PHP Tags
  • PHP Comments
  • How to display data on the browser
  • A note on line terminator
  • Installing PHP & Apache on your machine for development
  • Setting up Virtual Hosting on your machine for development

Fasten your seat belts and enjoy the lovely journey towards learning PHP 5.

About PHP5 Scripting Language

PHP5 is a scripting language for the web to render dynamic pages (See note below on dynamic and static pages). PHP is used for server side scripting and can also be used for developing CLI (Command Line Interface) programs. PHP is a recursive acronym for PHP: Hypertext Preprocessor.

Note on Dynamic and Static Pages

Initially when the World Wide Web was created all pages were static. This means that someone manually had to change the pages and upload it to the server again. This was a big issue in terms of creating a Web Application that would keep changing / updating a page depending on the data available in their database server.

Therefore, came the concept of CGI (Common Gateway Interface), through which you could ask for script pages instead of static HTML pages. Once a user hits the Script URL CGI would allow for the script engine to execute the page and throw HTML output to the browsers. This is called Dynamic Pages.

PHP Tags

With PHP it is possible to embed the presentation HTML along with your PHP Code. Therefore, for PHP to understand the area of your file where PHP code resides, you need to use PHP Tags.

Code Example:

<?php

echo “Hello World”;

? >
PHP allows 3 types of tags, as follows:

Standard Tags <?php
… code
?>
Short Tags <?=$variable?>
Script Tags <script language=”php”>
… code
</script>
ASP Tags <%
… code
%>

Standard tags are the de-facto opening and closing tags; they are the best solution for
portability and backwards compatibility, because they are guaranteed to be available
and cannot be disabled by changing PHP’s configuration file.

Short tags were, for a time, the standard in the PHP world; however, they do have
the major drawback of conflicting with XML headers and, therefore, have somewhat
fallen by the wayside. Their other advantage is the availability of the short form
<?=$variable ?> syntax, which allows you to print the result of an expression directly
to the script’s output.

Script tags were introduced so that HTML editors which were able to ignore
JavaScript but were unable to cope with the standard PHP tags could also ignore
the PHP code.

Nobody quite understands why ASP tags were introduced—however,
if you are so inclined you can turn on this optional configuration option, and you are
free to use them.

Note: Short tags, script tags and ASP tags are all considered deprecated and their use is
strongly discouraged.




PHP Comments

It is a good practice to comment your code. Comment is nothing but a textual explanation of what a piece of code does. This is necessary because over a period of time you as a developer would not remember how the logic works. Comments serve as inline documentation for the code and aids speedy maintenance activity.

PHP allows developers to comment as following:

Single line comment (//) <?php
//this logic does that
… code
?>
Single line comment (#) <?php
#this logic does that
… code
?>
Multi-line comment (/*…*/) <?php
/*this logic does that and requires
two lines of comments */
… code
?>

How to display data in PHP

PHP provides two methods of displaying data in the browser:

a) echo
b) print

Either of these statements can be used to display a string output on the browser or command line. Look at the examples below:

Example 1 : How to output a String
<?php

echo “Hello World”;
print “Hello World”;

?>

In the example above, look at the way Hello World has been enclosed in double quotes. Note that in PHP a string should be enclosed in double quotes. Though you could also enclose it with single quotes (‘Hello World’) because PHP is not type strict. But as a general practice it is better if you follow the double quote principle. By following this way of using string; if you keep developing projects across various different programming languages then the standard still gets maintained.




Example 2 : How to output a variable
<?php

$name = “Sunil Bhatia”;
echo “My name is ” . $name;
print “My name is ” . $name;

?>

In the example above we first assign a string to a variable $name (we will cover more about variables in the next tutorial). Look at how we have used the (.) dot operator to concatenate (join) two strings i.e. First String “My name is” and second string variable $name.

Concatenation means to join two strings so that the result of this operation becomes a joined string. The dot operator (.) is used to concatenate two strings. Just like we would use a + operator in Java or & operator in ASP.

A note on line terminators

As a developer you will be writing lines of code. But how would PHP know when a line of code is over. You would say that PHP should identify end of line because of the new line character i.e. <Enter> key. But there are many statements that you could be written on multiple lines or the same line. So, how would PHP identify end of line.

Like C, Java and C#; PHP also used a semi-colon (;) as a statement terminator. This is mandatory and should not be ignored.

Look at the example below

<?php

$name = “Sunil Bhatia”;
echo $name;

?>

Do you see that both the line of codes are terminated by a semi-colon (;).

Installing PHP & Apache on your machine for development

Installing PHP & Apache is easier than you think. Read this tutorial on the site to have a complete understanding:

How to Install Apache on Windows

The following link will help you understand how to configure PHP for Apache on Windows:

How to configure PHP on Apache for Windows

Setting up Virtual Hosting on your machine for development

Read this post on how to setup virtual hosting on your machine with Apache

Setting up Virtual Hosting in Apache on Windows

In the next tutorial we will learn about PHP Variables.

Cisco is considered one of the most important certification providers. Cisco exams CCNA IIUC Voice 640-460 and CCIE 350-029 are one of the most important certification exams. Cisco introduced 642-654 WAASSE Wide Area Application Services and 650-059 LCSARS Lifecycle Services Advanced Routing and Switching to enhance the network security. Microsoft MCSE 70-298 certification exam is the most popular exam.

Categories: PHP Tutorials Tags:

PHP5 Tutorials – Introduction

September 27th, 2007 Comments off

Being a veteran Java programmer and a big believer of OOAD concepts I have started toying with PHP5 – which the world says to be the next level of PHP.

Guys behind PHP5 have no doubt done a remarkable job by releasing this version at a much needed time when the entire PHP community were wanting their favorite PHP language with OOPS features.

PHP5 has a couple of good OOPS features like:

  • You can now write Destructor methods
  • You can now define access specifiers (public, private & protected)
  • You can now inherit from a base class, therefore function overriding is now possible
  • You can now define Abstract Classes
  • You can now create Interfaces
  • PHP has now introduced Method Type Hinting

Compared to Java PHP5 does not have much to offer, but I sincerely believe that its a positive start towards making PHP5 a language as well defined by Java.

PHP6 is now under active development where a lot of new features are being thought of and support for certain global variables are removed.

Following is the course content that I will publish regularly

1. Introduction to PHP Web Programming
2. PHP variables
3. PHP Decision making Structures
4. PHP Looping Structures
5. PHP Functions
6. PHP Form Processing
7. PHP Cookie Management
8. PHP Database Management
9. PHP Sample Web Application
10. PHP Introduction to OOPS Features
11. PHP Classes, Objects and Methods
12. PHP Inheritance
13. PHP Interfaces
14. PHP Polymorphism
15. PHP Magic Methods
16. About Zend PHP Certification

Keep visiting back to find more updates on this tutorial

Note
PHP team has announced the end of PHP 4 by the 31st of December 2007. Beyond this date, no more fixes and patches for PHP4 will be available.

Get our latest and emerging certification related to HP0-A01 HP-UX 11i v3 System Administration, Microsoft MCTS 70-236 and JN0-400 JNCIA-EX. We offer free pdf download of Cisco 642-105 IUM Implementing Cisco Unified Messaging and Cisco 642-533 IPS. Get money back guarantee in the case of failure in the IBM 000-100 certification exam in your first attempt.

Categories: PHP Tutorials Tags: