Comprehensive Overview of JAVA and PHP for Web Development

Verified

Added on  2020/03/07

|7
|993
|276
Report
AI Summary
This report provides a comprehensive overview of two prominent programming languages: Java and PHP. It begins with an introduction to Java, an object-oriented language used in diverse applications, detailing its syntax, which is derived from C-Language, and includes a practical programming example illustrating class structure and object instantiation within a juice shop application. The report then transitions to PHP, a server-side scripting language, highlighting its syntax based on C, Perl, and Java, and its utility in creating dynamic web content. It discusses the ways to escape PHP code and presents a basic PHP program example. References to related literature are also included, offering a foundation for understanding the core concepts and practical applications of both languages in web development.
Document Page
Running head: OVERVIEW ON JAVA AND PHP
Overview on Java and PHP
Name of the Student:
Name of the Organisation:
Author Note:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1OVERVIEW ON JAVA AND PHP
Table of Contents
1. Introduction to JAVA.............................................................................................................2
1.1. JAVA Syntax..................................................................................................................2
1.2. JAVA programming example.........................................................................................3
2. Introduction to PHP................................................................................................................4
2.1. PHP Syntax.....................................................................................................................4
2.2. Illustration of PHP Program............................................................................................4
3. References..............................................................................................................................6
Document Page
2OVERVIEW ON JAVA AND PHP
1. Introduction to JAVA
JAVA is an object oriented programming language that is used to develop many
applications in different environments. JAVA technology finds its uses from personal to
enterprise level systems. The JAVA language has its own unique code structure and syntax
parameters like all other programming languages. The code structure of JAVA is based on
the concept of Object Oriented Programming (OOP). JAVA is a derivative of C-Language.
Therefore, the syntax of JAVA is almost similar to that of C-Language. JAVA language
initiates with packages, which is its name space mechanism. Packages contain classes, which
in turn contains methods, constants, variables and such [1].
1.1. JAVA Syntax
To construct a JAVA program, the following syntax is required to be followed:
Case Sensitive – JAVA is case sensitive, therefore, the terms Goodbye and goodbye will
have different implications in a JAVA program [2].
Class Names – All class names should start with an upper case letter. In case of multiple
words involved in a class name, all the first letters of each word will be in upper case [2].
For Example: class HelloWorld
Method Names – The method names starts with a lower case letter. In case the method
name comprises of more than one word, all the words involved will have its first letter in
upper case [2].
For Example: public void myWorldTour()
Program File Name – The name of the program file should not be different from the class
name [2]. For example, a program with a class name HelloWorld should be saved as
HelloWorld.java as its file name.
Document Page
3OVERVIEW ON JAVA AND PHP
public static void main (String args []) – JAVA program processing begins with main()
method which is essential for all JAVA program [2].
1.2. JAVA programming example
An example of a JAVA program is provided below, which deals with an application
for a juice shop. The purpose of the application is to restrict the glass size to small, medium
and large to ensure that no other glass sizes are ordered other than the specified size [3].
Class FreshJuice {
enum FreshJuiceSize {SMALL, MEDIUM, LARGE}
FreshJuiceSize size;
}
public class FreshJuiceTest {
public static void main (String args[]) {
FreshJuice juice = new FreshJuice();
juice.size = FreshJuice.FreshJuiceSize.MEDIUM;
System.out.println (“Size:” + juice.size);
}
}
The output of the program will be as follows.
Size : MEDIUM
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4OVERVIEW ON JAVA AND PHP
2. Introduction to PHP
PHP is a server side scripting system. It stands for PHP: Hypertext Preprocessor. The
syntax of PHP is based on C, Perl and Java. PHP is effective for the development of dynamic
content. It is a strong but has certain risks associated to its use [4].
2.1. PHP Syntax
PHP follows a syntax, which is mostly based on C, Perl and Java.
Escaping to PHP – the parsing engine of PHP needs a method to separate the PHP
code from the other aspects in the page. The method is known as Escaping to PHP that has
four ways [5].
Canonical PHP Tags – for example: <?php...?>
Short-open (SGML Style) tags – for example: <?...?>
ASP-style tags – for example: <%...%>
HTML Script tags – for example: <script language=”PHP”>...</script>
Apart from the above methods other syntax are as follows:
It is whitespace insensitive.
It is case sensitive.
The expressions in the statements end with a semicolon.
Tokens combine to form an expression.
Blocks are made with Braces.
2.2. Illustration of PHP Program
The following example provided below is a basic illustration of a PHP program [6].
Document Page
5OVERVIEW ON JAVA AND PHP
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<?php
//Write out Hello World!
echo 'Hello World!';
?>
</body>
</html>
Document Page
6OVERVIEW ON JAVA AND PHP
3. References
[1] Layka, V., 2014. Introduction to JAVA. In Learn Java for Web Development (pp. 383-
398). Apress.
[2] Schildt, H., 2014. Java: The Complete Reference. McGraw-Hill Education Group.
[3] Reges, S. and Stepp, M., 2014. Building Java Programs. Pearson.
[4] Nixon, R., 2014. Learning PHP, MySQL, JavaScript, CSS & HTML5: A Step-by-Step
Guide to Creating Dynamic Websites. " O'Reilly Media, Inc.".
[5] Powers, D., 2014. PHP solutions: dynamic web design made easy. Apress.
[6] Tatroe, K., MacIntyre, P. and Lerdorf, R., 2013. Programming PHP: Creating Dynamic
Web Pages. " O'Reilly Media, Inc.".
chevron_up_icon
1 out of 7
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]