Server Side Script 3rd Year
Server Side Script 3rd Year
By: Eyachew T. 2|
Page
Among other things, it takes so much of the guesswork out of creating truly innovative software.
It’s also incredibly easy to learn, thanks to its clean syntax, making Ruby an especially popular pick
for beginning coders.
Ruby is a strictly object-oriented scripting language, so everything becomes an object when
working with it. This is even the case for factors like integers or Booleans which are usually more
primitive.
V. Perl
Perl is a general scripting language that’s been around a very long time since December of 1987, to
be exact. It started out as a UNIX language primarily used to process reports. (Its name even
originates from the phrase “practical extraction and reporting language”.)
Perl really began to gain traction throughout the 1990s when coders used it heavily for CGI
(common gateway interface), a specification most often seen today on legacy websites.
However, it remains fairly popular because of its innovation and suitability for text manipulation
tasks.
1.2.3. Advantages of Using Scripting Languages
By: Eyachew T. 3|
Page
Easy to learn and use Portable and cross-platform
Open-source and free Lighter memory requirement
1.2.4. Disadvantages of Using Scripting Languages
Lack of optimizations Organization requirements
Slower execution Time commitment on updates
1.3. Web Document Requirement
A website requirements document is an essential pioneer to initiating any website design project
for business owners. It serves as a comprehensive outline detailing the precise needs of the new
website. Providing a clear roadmap ensures that the website designer or developer constructs a
site that aligns with the owner’s objectives.
Having worked with several clients over the years, we believe the website requirements
document holds paramount significance in the web design process. It facilitates effective
communication of the owner’s vision to the designer, establishing mutual understanding
regarding the website’s overall objectives and essential features.
To ensure a comprehensive website requirement document, you must ensure you have these five
points checked off:
1. Outline a clear purpose and goals for the website.
2. Define your target audience.
3. Determine technical requirements and specifications.
4. Define content requirements.
5. Include wireframes and site maps.
By: Eyachew T.
4|Page
MySQL: Core of Data Management
MySQL, on the other hand, is a relational database management system. It allows you to store,
retrieve, and manipulate databases with which your PHP scripts interact. Whether building a
simple website or a complex web application, data management is a core function, making
MySQL an essential part of the PHP development process.
2.2Basic syntax of Server-side scripts
When we talk about popular programming languages, usually at the top of the list is PHP, a
favorite among developers and software engineers who use frameworks based on this language
to build modern and multifunctional web pages and applications.
PHP is one of the most popular scripting languages and works on the server side. Its acronym
means “Hypertext Preprocessor” in Spanish and it is embedded in HTML. It allows: creating
personalized web content, sending and receiving cookies, evaluating form data sent from a
browser, etc.
In addition to its features, it has integration with several popular databases like Postgre SQL,
Oracle, Sybase, SQL, and MySQL. It also handles forms, saves data to files, and collects data
from files.
II.1.1. Basic PHP Syntax
A PHP script can be placed anywhere in a document. This script starts with <?php and ends
with?>. We present an example:
The default extension of PHP files is: .php. A PHP file usually contains HTML tags and some
PHP script code.
The following is an example of a simple PHP file, with a script that uses a built-in echo function
to output the text "Hello world!" On a website:
By: Eyachew T.
5|Page
A variable name must start with a letter or underscore (_) character.
A PHP variable name cannot contain spaces.
One thing to be kept in mind that the variable name cannot start with a number or special
symbols.
PHP variables are case-sensitive, so $name and $NAME both are treated as different
variable.
A. PHP Variable: Declaring string, integer, and float
Let's see the example to store string, integer, and float values in PHP variables.
File: variable1.php
Output:
string is: hello string
integer is: 200
float is: 44.6
File: variable2.php
Output:
11
In PHP, variable names are case sensitive. So variable name "color" is different from Color,
COLOR, COLor etc.
File: variable3.php
Output:
By: Eyachew T.
6|Page
My car is red
Notice: Undefined variable: COLOR in C:\wamp\www\variable.php on line 4
My house is
Notice: Undefined variable: coLOR in C:\wamp\www\variable.php on line 5
My boat is
Output:
hello
hello
File: variableinvalid.php
Output:
Parse error: syntax error, unexpected '4' (T_LNUMBER), expecting variable (T_VARIABLE)
or '$' in C:\wamp\www\variableinvalid.php on line 2
II.1.3. PHP Data Types
PHP data types are used to hold different types of data or values. PHP supports 8 primitive data
types that can be categorized further in 3 types:
i. Scalar Types (predefined) iii. Special Types
ii. Compound Types (user-defined)
PHP Data Types: Scalar Types
It holds only single value. There are 4 scalar data types in PHP.
i. Boolean iii. float
ii. integer iv. string
PHP Data Types: Compound Types
It can hold multiple values. There are 2 compound data types in PHP.
i. array ii. object
PHP Data Types: Special Types
i. resource ii. NULL
II.1.4. PHP Operators
Operators are used to performing operations on some values. In other words, we can describe
operators as something that takes some values, performs some operation on them, and gives a
result. From example, “1 + 2 = 3” in this expression ‘+’ is an operator. It takes two values 1 and
2, performs an addition operation on them to give 3.
By: Eyachew T.
7|Page
Just like any other programming language, PHP also supports various types of operations like
arithmetic operations (addition, subtraction, etc), logical operations (AND, OR etc),
Increment/Decrement Operations, etc. Thus, PHP provides us with many operators to perform
such operations on various operands or variables, or values. These operators are nothing but
symbols needed to perform operations of various types. Given below are the various groups of
operators:
Arithmetic Operators Assignment Operators
Logical or Relational Operators Array Operators
Comparison Operators Increment/Decrement Operators
Conditional or Ternary Operators String Operators
II.1.5. PHP Comments
PHP comments can be used to describe any line of code so that other developer can understand
the code easily. It can also be used to hide any code.
PHP supports single line and multi line comments. These comments are similar to C/C++ and
Perl style (Unix shell style) comments.
A. PHP Single Line Comments
There are two ways to use single line comments in PHP.
// (C++ style single line comment)
# (Unix Shell style single line comment)
Output:
Welcome to PHP single line comments
By: Eyachew T.
8|Page
II. Loop Statements
Sometimes we may need to alter the flow of the program. If the execution of a specific code may
need to be repeated several numbers of times then we can go for loop statements.
In PHP, the following are loop statements
while loop for loop
do - while loop
III. Jump Statements
Jump statements in PHP are used to alter the flow of a loop like you want to skip a part of a loop or
terminate a loop.
In PHP, the following are jump statements
break statement continue statement
II.1.7. Differences between PHP and JavaScript
JavaScript is, like PHP, one of the most popular programming languages. It can be defined as a high-level,
dynamic, interpreted language used with HTML web applications. It is also used for non-web documents
such as PDFs and desktop widgets.
Among the main differences between both programming languages are:
PHP is a server-side scripting language while JavaScript is a client-side scripting language.
PHP does not run inside the browser, while JavaScript runs inside the browser.
PHP supports databases while JavaScript does not support databases.
PHP accepts variables in upper and lower case, while JavaScript does not.
When we compare PHP and JavaScript, PHP does not support swapping objects and arrays, while
JavaScript supports swapping objects and arrays.
HTML XHTML
XHTML (Extensible HyperText Markup Language) is a family of
HTML or HyperText Markup Language is the
XML markup languages that mirror or extend versions of the widely
main markup language for creating web pages
used Hypertext Markup Language (HTML)
Flexible framework requiring lenient HTML Restrictive subset of XML which needs to be parsed with standard
specific parser XML parsers
Proposed by Tim Berners-Lee in 1987 World Wide Web Consortium Recommendation in 2000.
Application of Standard Generalized Markup
Application of XML
Language (SGML).
Extended from SGML. Extended from XML, HTML
README File:
Create a README file to provide an overview of the project. Include information on installation,
configuration, usage, and any dependencies.
2. Version Control: Use version control (e.g., Git) to track changes and collaborate with a team. Commit
regularly with meaningful commit messages. Utilize branches for feature development and bug fixes.
3. Testing Documentation: Write PHPUnit tests for functions, methods, and classes. Document test cases
with clear descriptions and expected outcomes.
4. Deployment Documentation: Document the deployment process, including server requirements and
configurations. Specify any environment variables or settings needed for deployment.
5. API Documentation: If your project involves APIs, use Swagger or OpenAPI to document API
endpoints. Include details on request and response formats, authentication, and usage examples.
6. Submission for Approval: Address any issues or concerns raised during the review process. Clearly
define the approval workflow within your team or organization. Specify who needs to review and approve
changes before deployment.
7. Continuous Integration (CI): Integrate CI tools to automate checks for coding standards, tests, and
other quality measures. Ensure that CI passes before submitting code for approval.
8. User Manuals (if applicable): If your project has end-users, create user manuals or guides. Provide
clear instructions on how to use the application.
9. Communication: Communicate changes and updates to stakeholders, particularly if they involve user-
facing features. Provide demonstrations or walkthroughs if necessary.