1. Abstract
Open Source software is perceived as a free alternative to commercial software because no per
user or per computer charges are levied. There is now a wide range of Open Source software
available including operating systems and applications which in some cases can offer similar
functionality to commercial software with no licensing costs. In Part one this paper covers the
background and clarifies the terms used in Open Source developments and in Part two, it
documents current usage and identifies other factors which need to be considered before
selecting an Open Source solution.
When you buy a computer system you are buying the hardware and licensing the software. The
licensing terms control what actions can and cannot be performed and most software uses a
license designed to ensure that the creators of materials and resources are acknowledged and
rewarded for their work. This gives rise to the standard practice of charging a royalty per user or
per device using the software. Open Source software uses a different type of License aimed at
ensuring the software’s development and royalty free distribution.
2. Content
S.NO Name of topic Page no.
1. Chapter 1:-Introduction of Open Source 3
Technology
2. Chapter 2:-Literature Review 4-5
3. Chapter 3:-What is An Open Source 6
Technology
4. Chapter 4:-Example of open Source 9-43
Technology
5. Chapter 4:-Linux 9-21
6. Chapter 4:-PHP 22-43
7. Chapter 5:- Open Vs Closed Software 44
Technology
8. Chapter 6:- Advantages of open source 45
technology
9. Chapter 7:- Practical Examples Of Open 44-47
Source Technology
10. Chapter 8:- Conclusion &Feature Scope 48
11. Chapter 9:-Reference 49
ii
3. Chapter:-1
Introduction
Open Source software is perceived as a free alternative to commercial software because no per
user or per computer charges are levied. There is now a wide range of Open Source software
available including operating systems and applications which in some cases can offer similar
functionality to commercial software with no licensing costs. In Part one this paper covers the
background and clarifies the terms used in Open Source developments and in Part two, it
documents current usage and identifies other factors which need to be considered before
selecting an Open Source solution.
When you buy a computer system you are buying the hardware and licensing the software. The
licensing terms control what actions can and cannot be performed and most software uses a
license designed to ensure that the creators of materials and resources are acknowledged and
rewarded for their work. This gives rise to the standard practice of charging a royalty per user or
per device using the software. Open Source software uses a different type of license aimed at
ensuring the software’s development and royalty free distribution.
iii
4. Chapter:-2
Literature Review
Appropriate Technology
Open Design-Based Strategies to Enhance Appropriate Technology Development
Abstract: The appropriate technology (AT) movement is being driven by inventors and
innovators who are interested in designing technologies that are culturally,
environmentally, and economically appropriate, and feasible to construct and use for
people anywhere in the world. This paper examines how open sharing of designs,
specifications, and technical information can enhance effectiveness, widespread use, and
innovation of AT. This commons-based open design method has been highly successful
for software development (i.e., open source), and has also begun to be used in other fields
through unique partnerships and new information-sharing tools on the internet. This
paper critically demonstrates key examples of open design successes that can be applied
to development of AT. It also identifies potential barriers to open-sourcing AT designs,
analyzes business models for open design in the context of AT, and outlines practical
solutions with examples currently underway.
Overcoming Technical Constraints for Obtaining Sustainable Development with Open Source
Appropriate Technology
Abstract: Open source appropriate technology (OSAT) refers to technologies that provide
for sustainable development while being designed in the same fashion as free and open
source software. Facilitated by advances in information technology software and
hardware, new ways to disseminate information such as wikis and Internet-enabled
mobile phones, the global development of OSAT has emerged as a reality. This paper
shows the sharing of design processes, appropriate tools, and technical information is
enables more effective and rapid development of appropriate technologies for both
industrialized and non-industrialized regions. This sharing will require the appropriate
iv
5. technology community to adopt open standards/licenses, document knowledge, and build
on previous work. This paper offers solutions in the form of both business models and
tools to overcome technical constraints of OSAT development in the forms of the
platforms necessary on which to share and build knowledge about appropriate
technologies. These solutions are open, easily accessible for those in need, have a low
barrier to entry for both users and information creators, and must be vetted in order to
utilized as a trustworthy source on critical information needs. Current progress towards
implementing these solutions will be reviewed and recommendations will be made to
further increase the rate of OSAT development.
v
6. Chapter:-3
What is Open Source Technology?
Open Source technology can be defined as Computer Software for which the human-readable
source code is made available under a copyright License (or arrangement such as the Public
Domain) Open Source is a development methodology which offers practical accessibility to a
product's source (goods and knowledge).
This permits users to use, change, and improve the software, and to redistribute it in modified or
unmodified form.
The distribution terms of open-source software must comply with the following criteria:
1.Free Distribution
2.Source Code
3.Derived Works
4.No Discrimination Against Persons or Groups
vi
7. Chapter :-4
INTRODUCTION TO LINUX
LINUX is an open source / free software. With its advanced server configuration, Red Hat
is putting Linux as an operating system at the core of enterprise computing. Today Linux is
found in Web infrastructure, file server, ERP, and point of sale system, increasingly in the
systems running critical applications at large companies. Analysts predict that by the end of this
decade Linux will be a common element in the enterprise computing landscape.
“Over the last year, we’ve seen Linux go from being focused on small and medium
business to being used very deep in the enterprise”, says Paul Cormier, executive vice
president of engineering at Red Hat, a leading Linux platform provider.
vii
8. Salient Features of LINUX
1. Linux is the fastest operating system in the world. It runs much faster than Windows
9X/NT. It is about 1.2 to 3 times faster than Windows 9X/NT. In command-line console
mode without X-window it runs even faster (console mode is ideal for Database servers,
Apache Web servers, Email servers, News servers, File servers, DNS servers, Print
servers, Network Computer servers, etc..). Linux is also the most powerful yet most
simple and easy to use operating system in the world.
2. Linux is the most reliable OS. Windows 9X/NT fails the CRASH_OS_TEST Programs
and only Linux passes. Also commercial UNIX’s like IRIX, Solaris,
HPUX, AIX, SCO all fail the crash test and Linux is the only OS which passes the crash
me test. Very often Windows 95 users will get GPF errors and the system freezes
3. Linux is very robust because it is built by millions of people on internet and there are no
errors in the kernel. It runs for one full year without any re-boots or any problems non-
stop, guaranteed. It is the best designed OS.
4. Linux has an excellent scalability - it runs on Uni-processor, Multi-processors, Parallel
Processors and even Super-computers. It fully supports SMP (Symmetric Multi-
Processing) boxes with more than one CPU. Windows 95 supports only one CPU box.
Linux scales much better than NT on SMP.
5. Linux is fully 32-bit & 64-bit operating system. And it is very modular and is
viii
9. already ported to 64-bit chips like DEC alpha, Sun Microsystems UltraSparc, Intel IA64,
Motorola PowerPC, Transmeta Corp Crusoe chip and GNU/GPL Freedom 64-bit CPU.
Whereas Windows 95 has a major chunks of 16-bit code in its kernel and MS Windows
runs only on one type of chip - "Intel chip".
6. Linux is a very secure OS. Windows 95 is not a secure OS, break-ins are easy. Windows
95/2000, NT, MSDOS have computer viruses. But Linux does not have any viruses.
Computer viruses cause lot of damages to Windows 95/2000/NT but not to Linux.
7. Linux is very mature and is one of the oldest operating system in the world. UNIX
(which is another name for Linux) was born in AT&T Bell Labs 27 years ago for
Telecom research. Linux (UNIX) is the end-result of 27 years of research and
development effort by U.S/European Universities and mega-corporations of Europe /
America. It took 27 years to create vast amount of UNIX information, and all that info is
now just sitting inside this Linux cdrom on our hand. For example programs like 'grep'
had not changed for the past 27 years and they are still used in Linux. Functionality and
command line options of grep had not changed for the past 27 years. Linux started the
Linux during 1991, but he borrowed lot of concepts, code from UNIX and this means
Linux is 27 years old. Today Linux is the OCEAN wherein all other unixes like Solaris,
HPUX, and AIX merge into. And in near future all other unixes will be replaced by
Linux.
8. Linux is less demanding on system resources. Linux runs on 386 PC with as little as 2
MB RAM in command-line console mode. Windows 95/NT cannot because the graphic
engine is included in the kernel, which makes Windows 95/NT a resource hog. Graphic
engine makes the Windows 95/NT extremely unreliable and unpredictable. Linux can do
everything that Windows 95/NT does but Windows 95/NT cannot do everything which
Linux does. In Windows 95/NT there is no option for the user to run in command-line
console mode without any graphics. Unlike Windows95, X-window can run with very
ix
10. minimum resources, it runs on 486 boxes with just 8MB of RAM.
Linux uses X-window which is an advanced network-windowing system, whereas Windows
95/NT is a standalone single-workstation windowing system. For example, using X-
window, users can display output on any workstation-monitor attached anywhere in the
network. There is a command called "xhost" in Linux and display environment variable,
export display=`hostname`:0.0. Like this there are lots of functionalities in X-window which
are missing in Windows NT/95. X-Window is an industry standard which was developed in
MIT and is a very powerful network windowing system. With X-window you can run
programs on super-computers and display on your Linux desktop locally. Even though X-
window is network-resource intensive, it is becoming increasingly popular because of the
availability of very low cost, high speed networking like 1 Gig bit Ethernet cards, 100
Megabit Ethernet cards, DSL lines, Cable-Modems, Frame-relay and ATM networks.
9. Linux has very low total cost of ownership since Linux supports diskless nodes. Cost of
maintaining Linux is five times lower than MS Windows.
10. Linux supports remote system administration whereas Windows NT/95 does not. We can
remote login and do many system administration tasks, for example like adding users,
reboot a Linux server from a remote terminal hundreds of miles.
11. Linux runs most windows applications (16bit) like MSOffice, MSWord using WABI
($40), WINE (free) and MSDOS applications using DOSemu, FreeDOS, and Dr.DOS.
But Windows95/NT will run only few of UNIX and Linux applications.
12. Linux supports su (super user) command. Using su command it is possible to switch user
without logging off. For example 'su - root' will login as user 'root'. In Windows NT/95
x
11. you must log off completely to switch user. Linux has remote commands like 'rlogin',
telnet, etc. While Windows NT/95 does not have.
13. Linux kernel is very small and it can fit on a single floppy. It is less complex but very
sophisticated and powerful. Small kernel means it is very reliable. Linux applications are
much bigger running on top of the Linux Kernel.
14. Linux has many powerful desktops like KDE desktop, GNOME, Triteal CDE, Moti
mwm, Open look low, twm, fvwm95, xdm, xsm, Windows Afterstep, Window maker
(NeXTstep-lookalike), Qvwm, amiwm (amiga), mlvwm (mac) etc. KDE desktop is much
more user friendly than Windows95! You have more freedom and choice in Linux
desktops as compared to Windows 9X/NT.
15. Linux OS needs only 200 MB of disk space for installation. Linux supports dual boot on
the PCs - that is, you can have Windows95/NT on one partition and Linux on other.
During system startup user can select to load Linux or Windows 95 and vice versa.
Nowadays PCs are shipped with 6 Gigs of disk space.
16. Linux runs on many hardware platforms - Intel, Motorola, PowerPC, RISC, DEC Alpha,
MIPS, ARM, Transmeta Crusoe, Sparc architectures and GNU Freedom-64-bit CPU.
Linux is already ported to 1024 CPUs super computer (Fujistu, Hitachi, Sun, Intel &
others). Intel corporation had built the world's fastest super-computer with 10240 Intel
Pentium CPU’s (more than ten thousand CPU’s) which is based on a system similar to
Linux.
17. Linux is 100% POSIX compliant OS, whereas Windows NT/9X are not. POSIX is IEEE
(Institute of Electrical Engg) standard as well as ANSI and international ISO standard
spec. U.S. govt generally require full compliance of POSIX on any operating system.
Most of the Unix's like Solaris, HPUX, AIX, SCO are 100% POSIX
xi
12. 18. We can get the complete source code for Linux OS and all of its applications, whereas
Windows 9X/NT is proprietary and we get only the binaries. Having the source code of
Linux is vital for companies because they can quickly add advanced features and share it
with every other company in the world.
19. Linux is free of any cost. Downsides of Windows 9X/ NT is that we need to pay $200
(US dollars) per seat for Windows 95 and $800 (US dollars) per seat for Windows NT.
And Microsoft applications like MS Office, C++ compilers and others will cost further
$400,000 US dollars. It is better to spend money on hardware and use Linux as the
software.
20. Linux is trouble free and we will not have any problems with Linux, whereas you will
have more headaches with Windows 95/NT (MS is not as reliable as Linux).
21. Linux more than 1900 software packages on cdrom and many more are being developed
world-wide. All the software packages are in a single Linux cdrom.
22. Linux was awarded ―The best Network Operating system 1997/98/99/2000‖, by many
computer magazines’ (US InfoWorld, European publications).
23. The movie Titanic was created using Linux on Digital Alpha. Linux was used to create
computer graphics, animations of all the shots in the movie Titanic.
24. Linux was also used for storing data from experiments in the space shuttle. Linux was
orbiting the earth in space.
xii
13. Advantages of Linux:-
Virus proof Advanced OS Crash proof
Economical Secured Fully supported
Multi-user Multi-tasking Multi-desktop
Powerful networking Variety of servers
LINUX INSTALLATION
Before Linux installation, you must really know about what is hard drive partition. For Linux
installation we need to insert the installation cd of Red Hat Linux to CDROM and boot. Most of
the installers give you an option between text and graphical install; you need to select ―text‖ if
your computer memory is restricted.
Linux software comes in packages. No matter what distribution or version of Linux you have,
the CD contains packages that make the base operating system a rich selection of networking
―clients‖ and ―servers‖ with appropriate configuration and monitoring tools, some end-user text
mode application, base X-window system and at least one GUI desktop.
The installation program will ask you several things to do like type of boot loader configuration.
It is better to select GRUB boot loader configuration. After this you will be asked to select the
type of doing partitions. It is recommended to choose disk druid type. In this you will be asked to
do partitions on available free space. In Linux there is all file system concept unlike windows.
The minimum required file system for installation of Linux are /, /boot, swap and /usr. After
doing these partitions the procedure will ask which packages to install. If you select
xiii
14. ―workstation‖ the packages normally found on servers are omitted from your installation. If you
select server installation then the end-user applications will not be installed. You can also chose
to install ―everything‖, best option for installation on personal computers at your home for new
users. For expertise users there is an option of selecting individual packages as per your
requirement. Now installation of Linux all in the form of packages starts and takes time
according to the packages selected. After completion the system reboots and Linux will start
successfully.
Types of installation Method
1.CD-ROM
2.NFS
3.FTP
4.HTTP
5.HARD DISK
6.Through kickstart method
Types of Boot loader
1.GRUB
2.LILO
Hard Disk Partitioning Method
1.Disk druid
2.fdisk
xiv
15. LINUX KERNEL & SHELL
KERNEL
The core of the Linux system is the kernel-the operating system program. The kernel controls the
resources of the computer, allotting them to different users and tasks. It interacts directly with the
hardware, thus making the programs easy to write and portable across different platform of
hardware. Since the kernel communicates directly with the hardware, the parts of the kernel must
be customized to the hardware features of each system. However, the kernel does not deal
directly with a user. Instead, the login process starts up a separate, interactive program, called the
shell, for each user.
SHELL
Linux has a simple user interface called the shell that has the power to provide the services that a
user wants. It protects the user from having to know the intricate hardware details.
xv
16. Feature of Shell:
Command Execution
Redirection
Background processing
History
Aliases
Variables
File Name Expansion
Command completion
Types of Shell in Linux:
Bash- ―Bourne Again Shell‖
Pdksh-―Public Domain Korn Shell‖
Tcsh- ―Tom’s C Shell‖
Ash- ―A Shell‖
Zsh- ― Z Shell‖
xvi
17. LINUX NETWORKING
For networking firstly your hardware must be properly configured. Your network card should
have been setup during the Linux installation or after the installation. Under Linux most drivers
for network cards are implemented as modules, after the module is inserted, you may want to
inspect the file /proc /modules to see if the module is loaded. The module configuration file is
modules. conf in /etc. After setting up the network and connecting the cables, set up the network
by running the command: - net config
While setting up the network, doesn’t mess up with the ―loop back driver‖ which has the IP
address 127.0.0.1. It is always there-it is the IP through which the computer talks to itself. IP
address is allocated either statically or dynamically.
For Linux Networking (communication through a network), the two basic Requirements are
Media and Rules:-
By media we mean the communication link (cables), hubs and switches. It may be wired or
wireless. Hubs are dumb, not an intelligent device. It works at the Physical layer whereas
Switches are intelligent devices and works at Data link layer. To obtain good performance we
make use of Switches. In a Switch, direct routing is possible, the data packet is unicasted and not
broadcasted, the packet doesn’t traverse to all the port but direct connection is made via IP
address. Thus it has high performance; Switches maintain the IP address table for mapping
process.
By rules we mean the set of protocols used for communication. Rules or the Protocol to be used
depends on the OS on the end systems, if both the end- Systems have MS-Windows then for
small network we use Net bui protocol & for larger networks use of TCP/IP is made. End
systems having LINUX as OS Make use of TCP/IP protocol.
xvii
18. Some Basic Networking Command
1) Ping – Measures connectivity and network latency between local & remote system. It
uses ICMP echo packets.
Example: ping 192.168.0.6
Or
ping www.redhat.com
1) Traceroute – Shows network path between local and remote systems.
Useful for pinpointing network congestion.
Example: trace route www.redhat.com
1) Netstat – Lists network statistics and parameters, including Network
Connection, Routing table, Interface statistics.
Example: netstat –rn
Or
netstat –a
1) ifup/ifdown - For each installed network adapter, there is a
Corresponding ifcfg-* file in/etc/sysconfig/network- Scripts.
You can activate or deactivate that adapter with
the ifup and ifdown commands. Either one of the Following commands will activate the
eth0 network
xviii
19. 1) Ifconfig - The ifconfig command is used to configure and display network devices.
Here is some sample output of an ifconfig command:
# /sbin/ifconfig eth0
Eth0 Link encap: Ethernet HWaddr 00:50:56:40:1E:6A
Inet addr: 192.168.199.131 Bcast: 192.168.199.255 Mask: 255.255.255.0
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU: 1500 Metric: 1
RX packets: 11253 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 1304 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 100
RX bytes: 2092656 (1.9 Mb) TX bytes: 161329 (157.5 Kb)
Interrupt: 10 Base addresses: 0x10a0
# /sbin/ifconfig eth0 207.174.142.142
The first parameter, eth0, tells us which interface is being configured. The next
Argument, 207.174.142.142, indicates the new IP address being assigned to this interface. If we
want to make sure our change worked, we issue the ifconfig command again to view its current
settings.
# /sbin/ifconfig eth0
Eth0 Link encap: Ethernet HWaddr 00:50:56:40:1E:6A
Inet addr: 207.174.142.142 Bcast: 192.168.199.255 Mask: 255.255.255.0
xix
20. UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU: 1500 Metric: 1
RX packets: 11253 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 1304 errors: 0 dropped: 0 overruns: 0 carrier: 0
APACHE WEB SERVER
Apache is Red Hat’s standard web server.
Apache is the most widely used web server. More then 60% sites are hosted on apache web
server.
Apache provides very stable and scalable web server platform.
Apache support virtual hosts in which multiple web sites may share the same web server.
Service profile: Apache
Type: System V-launched service
Packages: httpd
Daemons: httpd
Script: httpd
Ports: 80/tcp (http), 443/tcp (https)
Configuration: /etc/httpd/*, /var/www/*
xx
21. Installing the Apache Server
1. Mount the Red Hat RPM source files for Apache. They may be located on CD or you
may have copied them in a previous chapter to a network source.
2. Locate the Apache RPM packages: httpd, httpd-devel, redhat-config-httpd,
mod_python, autoconf, automake, libtool, mod_perl, and mod_ssl. If you can’t find
some of these packages; you may have to repeat steps 1–3 with a different Red Hat
Installation CD.
3. Load the Apache RPM packages.
4. Use chkconfig to verify that Apache is not configured to start.
5. Now, use chkconfig to start Apache for runlevels 3 and 5.
6. Start Apache by hand by invoking the Apache management script (httpd) in
/etc/rc.d/init.d. Start a Web browser such as Mozilla or Konqueror. Point it at
http://localhost.
7. You should see the default Apache Web page for Red Hat Linux.
8. Close your Web browser.
xxi
22. Chapter :-4
2.PHP Introductio
PHP is a powerful tool for making dynamic and interactive Web pages.
PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
In our PHP tutorial you will learn about PHP, and how to execute scripts on your server.
PHP was originally created by Rasmus Lerdorf in 1995. The main implementation of PHP is
now produced by The PHP Group and serves as the formal reference to the PHP language.[6]
PHP is free software released under the PHP License, which is incompatible with the GNU
General Public License (GPL) due to restrictions on the usage of the term PHP.[7]
While PHP originally stood for "Personal Home Page", it is now said to stand for "PHP:
Hypertext Preprocessor", a recursive acronym.[8]
PHP is a server-side scripting language.
What You Should Already Know
Before you continue you should have a basic understanding of the following:
HTML/XHTML
JavaScript
xxii
23. If you want to study these subjects first, find the tutorials on our Home page.
What is PHP?
PHP stands for PHP: Hypertext Preprocessor
PHP is a server-side scripting language, like ASP
PHP scripts are executed on the server
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL,
Generic ODBC, etc.)
PHP is an open source software
PHP is free to download and use
What is a PHP File?
PHP files can contain text, HTML tags and scripts
PHP files are returned to the browser as plain HTML
PHP files have a file extension of ".php", ".php3", or ".phtml"
What is MySQL?
MySQL is a database server
MySQL is ideal for both small and large applications
MySQL supports standard SQL
MySQL compiles on a number of platforms
MySQL is free to download and use
PHP + MySQL
xxiii
24. PHP combined with MySQL are cross-platform (you can develop in Windows and serve
on a Unix platform)
Why PHP?
PHP runs on different platforms (Windows, Linux, Unix, etc.)
PHP is compatible with almost all servers used today (Apache, IIS, etc.)
PHP is FREE to download from the official PHP resource: www.php.net
PHP is easy to learn and runs efficiently on the server side
Where to Start?
To get access to a web server with PHP support, you can:
Install Apache (or IIS) on your own server, install PHP, and MySQL
Or find a web hosting plan with PHP and MySQL support
xxiv
25. PHP Installation
What do you Need?
If your server supports PHP you don't need to do anything.
Just create some .php files in your web directory, and the server will parse them for you. Because
it is free, most web hosts offer PHP support.
However, if your server does not support PHP, you must install PHP.
Here is a link to a good tutorial from PHP.net on how to install PHP5:
http://www.php.net/manual/en/install.php
Download PHP
Download PHP for free here: http://www.php.net/downloads.php
Download MySQL Database
Download MySQL for free here: http://www.mysql.com/downloads/
Download Apache Server
Download Apache for free here: http://httpd.apache.org/download.cgi
xxv
26. PHP Syntax
PHP code is executed on the server, and the plain HTML result is sent to the browser.
Basic PHP Syntax
A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be
placed anywhere in the document.
On servers with shorthand support enabled you can start a scripting block with <? and end with
?>.
For maximum compatibility, we recommend that you use the standard form (<?php) rather than
the shorthand form.
<?php
?>
A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.
Below, we have an example of a simple PHP script which sends the text "Hello World" to the
browser:
<html>
<body>
xxvi
27. <?php
echo "Hello World";
?>
</body>
</html>
Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to
distinguish one set of instructions from another.
There are two basic statements to output text with PHP: echo and print. In the example above
we have used the echo statement to output the text "Hello World".
Note: The file must have a .php extension. If the file has a .html extension, the PHP code will
not be executed.
xxvii
28. PHP Variables
A variable is used to store information.
Variables in PHP
Variables are used for storing values, like text strings, numbers or arrays.
When a variable is declared, it can be used over and over again in your script.
All variables in PHP start with a $ sign symbol.
The correct way of declaring a variable in PHP:
$var_name = value;
New PHP programmers often forget the $ sign at the beginning of the variable. In that case it
will not work.
Let's try creating a variable containing a string, and a variable containing a number:
<?php
$txt="Hello World!";
$x=16;
?>
PHP is a Loosely Typed Language
In PHP, a variable does not need to be declared before adding a value to it.
xxviii
29. In the example above, you see that you do not have to tell PHP which data type the variable is.
PHP automatically converts the variable to the correct data type, depending on its value.
In a strongly typed programming language, you have to declare (define) the type and name of the
variable before using it.
In PHP, the variable is declared automatically when you use it.
Naming Rules for Variables
A variable name must start with a letter or an underscore "_"
A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-
9, and _ )
A variable name should not contain spaces. If a variable name is more than one word, it
should be separated with an underscore ($my_string), or with capitalization ($myString)
xxix
30. String Variables in PHP
String variables are used for values that contain characters.
In this chapter we are going to look at the most common functions and operators used to
manipulate strings in PHP.
After we create a string we can manipulate it. A string can be used directly in a function or it can
be stored in a variable.
Below, the PHP script assigns the text "Hello World" to a string variable called $txt:
<?php
$txt="Hello World";
echo $txt;
?>
The output of the code above will be:
Hello World
Now, lets try to use some different functions and operators to manipulate the string.
The Concatenation Operator
There is only one string operator in PHP.
The concatenate on operator (.) is used to put two string values together.
To concatenate two string variables together, use the concatenation operator:
xxx
31. <?php
$txt1="Hello World!";
$txt2="What a nice day!";
echo $txt1 . " " . $txt2;
?>
The output of the code above will be:
Hello World! What a nice day!
If we look at the code above you see that we used the concatenation operator two times. This is
because we had to insert a third string (a space character), to separate the two strings.
The strlen() function
The strlen() function is used to return the length of a string.
Let's find the length of a string:
<?php
echo strlen("Hello world!");
?>
The output of the code above will be:
12
The length of a string is often used in loops or other functions, when it is important to know
when the string ends. (i.e. in a loop, we would want to stop the loop after the last character in the
string).
The strpos() function
xxxi
32. The strpos() function is used to search for a character/text within a string.
If a match is found, this function will return the character position of the first match. If no match
is found, it will return FALSE.
Let's see if we can find the string "world" in our string:
<?php
echo strpos("Hello world!","world");
?>
The output of the code above will be:
6
The position of the string "world" in the example above is 6. The reason that it is 6 (and not 7), is
that the first character position in the string is 0, and not 1.
Complete PHP String Reference
For a complete reference of all string functions, go to our complete PHP String Reference.
The reference contains a brief description, and examples of use, for each function!
xxxii
33. PHP Operators
Operators are used to operate on values.
PHP Operators
This section lists the different operators used in PHP.
Arithmetic Operators
Operator Description Example Result
+ Addition x=2 4
x+2
- Subtraction x=2 3
5-x
* Multiplication x=4 20
x*5
/ Division 15/5 3
5/2 2.5
% Modulus (division remainder) 5%2 1
10%8 2
10%2 0
++ Increment x=5 x=6
x++
xxxiii
34. -- Decrement x=5 x=4
x--
Assignment Operators
Operator Example Is The Same As
= x=y x=y
+= x+=y x=x+y
-= x-=y x=x-y
*= x*=y x=x*y
/= x/=y x=x/y
.= x.=y x=x.y
%= x%=y x=x%y
Comparison Operators
Operator Description Example
== is equal to 5==8 returns false
!= is not equal 5!=8 returns true
<> is not equal 5<>8 returns true
> is greater than 5>8 returns false
xxxiv
35. < is less than 5<8 returns true
>= is greater than or equal to 5>=8 returns false
<= is less than or equal to 5<=8 returns true
Logical Operators
Operator Description Example
&& And x=6
y=3
(x < 10 && y > 1) returns true
|| Or x=6
y=3
(x==5 || y==5) returns false
! Not x=6
y=3
!(x==y) returns true
xxxv
36. PHP If...Else Statements
Conditional statements are used to perform different actions based on different conditions.
Conditional Statements
Very often when you write code, you want to perform different actions for different decisions.
You can use conditional statements in your code to do this.
In PHP we have the following conditional statements:
if statement - use this statement to execute some code only if a specified condition is true
if...else statement - use this statement to execute some code if a condition is true and
another code if the condition is false
if...elseif....else statement - use this statement to select one of several blocks of code to
be executed
switch statement - use this statement to select one of many blocks of code to be executed
The if Statement
Use the if statement to execute some code only if a specified condition is true.
Syntax
if (condition) code to be executed if condition is true;
The following example will output "Have a nice weekend!" if the current day is Friday:
<html>
<body>
<?php
$d=date("D");
xxxvi
37. if ($d=="Fri") echo "Have a nice weekend!";
?>
</body>
</html>
Notice that there is no ..else.. in this syntax. The code is executed only if the specified condition
is true.
The if...else Statement
Use the if....else statement to execute some code if a condition is true and another code if a
condition is false.
Syntax
if (condition)
code to be executed if condition is true;
else
code to be executed if condition is false;
Example
The following example will output "Have a nice weekend!" if the current day is Friday,
otherwise it will output "Have a nice day!":
<html>
<body>
<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
xxxvii
38. else
echo "Have a nice day!";
?>
</body>
</html>
If more than one line should be executed if a condition is true/false, the lines should be enclosed
within curly braces:
<html>
<body>
<?php
$d=date("D");
if ($d=="Fri")
{
echo "Hello!<br />";
echo "Have a nice weekend!";
echo "See you on Monday!";
}
?>
</body>
</html>
The if...elseif....else Statement
Use the if....elseif...else statement to select one of several blocks of code to be executed.
xxxviii
39. Syntax
if (condition)
code to be executed if condition is true;
elseif (condition)
code to be executed if condition is true;
else
code to be executed if condition is false;
Example
The following example will output "Have a nice weekend!" if the current day is Friday, and
"Have a nice Sunday!" if the current day is Sunday. Otherwise it will output "Have a nice day!":
<html>
<body>
<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
elseif ($d=="Sun")
echo "Have a nice Sunday!";
else
echo "Have a nice day!";
?>
</body>
</html>
xxxix
40. PHP Switch Statement
Conditional statements are used to perform different actions based on different conditions.
The PHP Switch Statement
Use the switch statement to select one of many blocks of code to be executed.
Syntax
switch (n)
{
case label1:
code to be executed if n=label1;
break;
case label2:
code to be executed if n=label2;
break;
default:
code to be executed if n is different from both label1 and label2;
}
This is how it works: First we have a single expression n (most often a variable), that is
evaluated once. The value of the expression is then compared with the values for each case in the
structure. If there is a match, the block of code associated with that case is executed. Use break
to prevent the code from running into the next case automatically. The default statement is used
if no match is found.
Example
<html>
<body>
xl
41. <?php
switch ($x)
{
case 1:
echo "Number 1";
break;
case 2:
echo "Number 2";
break;
case 3:
echo "Number 3";
break;
default:
echo "No number between 1 and 3";
}
?>
</body>
</html>
xli
42. Chapter:-5
Open Vs Closed Software Technology
Open source software is based around the idea that the user can not only view, but change the
source code of an application.
Closed source software is hidden to prevent the user either viewing or changing the code.
After initial production, open source software is released to the development community and
undergoes a secondary phase of evolution. It is scrutinised by thousands of professional
developers across the globe who highlight potential flaws, bugs and security glitches.
Closed source software is developed in isolation with a small team of developers. It isn't possible
to build a team of hundreds to check the code because the code is deemed proprietary and secret.
xlii
43. Chapter:-6
Advantages of open source technology:
The "Open Source Model" is not a religion. It is a very practical way of develop software in a
rapidly changing environment.
Lower total cost of ownership
Reduced dependence on software vendors
open source software gives you the power to control your software's code. You have the right to
modify the code to suit your requirements and control the budgets that you want to spend
towards it.
Easier to customize
DISADVANTAGE OF OPEN SOURCE TECHNOLOGY
Most open source software applications are not reliable
No guarantee of updates Since you are not paying for the open source software nobody is bound
to give you regular updates. You can get stuck with the same old version for years without ever
getting an update.
xliii
44. Chapter:-7
Practical Examples Of Open Source Technology:
The Apache Web Server is the most widely used web server on the Internet. The Apache
Software Foundation was formed to provide support Apache an related software.
In addition, the operating system that we run on our website and almost everywhere else is
RedHat Linux.
Along with internet address system Internet Protocol, and the internet browser Mozilla Forefox.
One of the most successful programs is the Linux operating system, an open source Unix-like
operating system.
Companies Opting For Open Source Technology:
Google Chrome source code is available as an open source project called Chromium (BSD
license).
xliv
45. Microsoft Corp. released the first public beta for its Windows Server 2003 Compute Cluster
Edition, which is designed to address the high-performance computing needs of its customers,
particularly at the departmental and workgroup levels, and forms part of the Windows Server
line of products which is also a open source code
Nokia, alogwith hosting company CollabNet, will launch the OSTdev.net Web site where
developers can come together to create a wide range of home entertainment software for Nokia's
Open Standards Terminal software platform, based on Linux, Xfree and Mozilla.
Linux Entirely is made in open source technology.
xlv
46. Related work/ Existing systems/concept :
Open source software is software whose source code is published and made available to the
public, enabling anyone to copy, modify and redistribute the source code without paying
royalties or fees. Open source code evolves through community cooperation. These communities
are composed of individual programmers as well as very large companies. Examples of open-
source software products are:
xlvi
47. Programming languages:
PHP - Scripting language suited for the web
PYTHON - Scripting language for window applications
RUBY - Scripting language
OS:
GNU Project — ―a sufficient body of free software‖
Linux — operating system kernel based on Unix
NetBSD - operating system derived from Unix
OpenBSD — operating system derived from Unix
FreeBSD — operating system derived from Unix
OpenSolaris — Unix Operating System from Sun Microsystems
Symbian — real-time mobile operating system
xlvii
48. Chapter:-8
Conclusion & Feature Scope
The members of the independent software industry have led us into a time of change not seen by
the world since the industrial revolution. The billions of dollars of investment they havemade in
the development of their technology never would have come about without protection of the
fruits of their intellectual labors. At the same time, open source software is well established
as part of the software ecosystem and affords software developers and users an
importantalternative style of software development and distribution. There is a need and a
purpose for both.
In making decisions about whether to adopt open source software solutions or pay
forcommercial ones, it is important to consider how the open source solution compares to the For
the Free Software Foundation’s answers to questions about the GPL and LGPL, see
http://www.fsf.org/licenses/gpl-faq.html.
commercial one in terms of not only its technical characteristics, but also in terms of the overall
investment and total cost of ownership. It is also important to consider whether the use of an
open source solution would meet the user’s needs with respect to operational compatibility with
other programs and with respect to the user’s need to transact and interact with third parties
inindustries and markets in which commercial products are the de facto standard.
Finally, it is important to be aware that the open source movement is motivated not
onlytoprovide benefits to the software developer and user communities through the distribution
of ―free‖ software, but also to eliminate the need to use proprietary software. Through
lobbyingand other efforts, the open source movement has persuaded some companies and even
some Governments to adopt a bias toward open source products, and the GNU Project’s GPL
and LGPL have raised many serious questions about the proprietary integrity of software
developed
xlviii
49. Chapter:-9
References
Operating Systems (ASPLOS) (ACM, Cambridge, MA, 1996) 84.92. Available from
http://www.thekkath.org/papers/petal.pdf.
National Laboratory, CA, UCRL-WEB-148418, from
http://www-phys.llnl.gov/Research/Metals_Alloys/Methods/GreenFunc/.
www.in.redhat.com
www.freelinux.org
www.wiliesystem.com
www.linux.org
www.linuxdig.com
www.linux-howto.com
www.w3schools.com
xlix