Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

HyperText PreProcessor

Rating
-
Sold
-
Pages
52
Uploaded on
19-04-2023
Written in
2022/2023

This Document related to Web Technologies

Institution
Course

Content preview

UNIT - I

Introduction to PHP: Declaring variables, data types, arrays, strings, operators,
expressions, control structures, functions, Reading data from web form controls like
text boxes, radio buttons, lists etc., Handling File Uploads, Connecting to database
(MySQL as reference),executing simple queries, handling results, Handling sessions
and cookies.
File Handling in PHP: File operations like opening, closing, reading, writing,
appending, deleting etc. on text and binary files, listing directories

Introduction

PHP (Hypertext Preprocessor) is an open source, interpreted and object-oriented
scripting language i.e. executed at server side. It is used to develop web applications
(an application i.e. executed at server side and generates dynamic page). It was
developed by Rasmus Lerdorf in 1994.

PHP Features:

Performance: Script written in PHP executes much faster then those scripts written
in other languages such as JSP & ASP.

Open Source Software: PHP source code is free available on the web, you can
developed all the version of PHP according to your requirement without paying any
cost.

Platform Independent: PHP are available for WINDOWS, MAC, LINUX & UNIX
operating system. A PHP application developed in one OS can be easily executed in
other OS also.

Compatibility: PHP is compatible with almost all local servers used today like
Apache, IIS etc.

Embedded: PHP code can be easily embedded within HTML tags and script.

Install PHP

To install PHP, we will suggest you to install AMP (Apache, MySQL, PHP) software
stack. It is available for all operating systems. There are many AMP options available
in the market that are given below:
WAMP for Windows
LAMP for Linux
MAMP for Mac
SAMP for Solaris
FAMP for FreeBSD
XAMPP (Cross, Apache, MySQL, PHP, Perl) for Cross Platform: It includes some
other components too such as FileZilla, OpenSSL, Webalizer, Mercury Mail etc.

,If you are on Windows and don't want Perl and other features of XAMPP, you should
go for WAMP. In a similar way, you may use LAMP for Linux and MAMP for
Macintosh.

PHP Variables
A variable in PHP is a name of memory location that holds data. A variable is a
temporary storage that is used to store data temporarily.

In PHP, a variable is declared using $ sign followed by variable name. Syntax of
declaring a variable in PHP is given below:
$variablename=value;

Rules for PHP variables:
• A variable starts with the $ sign, followed by the name of the variable
• A variable name must starts with a letter or the underscore symbol
• Variable names consist of letters ,digits and underscore symbol (A-z, 0-9, and
_)
• White spaces are not allowed
• These can be of any length.
• Variable names are case-sensitive ($vaag and $VAAG are two different
variables)
Ex: $abc $_xyz $lmn12

PHP Echo
PHP echo is a language construct not a function, so you don't need to use
parenthesis with it. But if you want to use more than one parameters, it is required
to use parenthesis.
The syntax of PHP echo is given below:

void echo ( string $arg1 [, string $... ] )
PHP echo statement can be used to print string, multi line strings, escaping
characters, variable, array etc.

PHP echo: printing string
File: echo1.php

<?php
echo "Hello by PHP echo";

?>

Output: Hello by PHP echo

,PHP echo: printing multi line string
File: echo2.php

<?php
echo "Hello by PHP echo
this is multi line
text printed by
PHP echo statement ";

?>

Output:

Hello by PHP echo this is multi line text printed by PHP echo statement

PHP echo: printing escaping characters
File: echo3.php

<?php
echo "Hello escape \"sequence\" characters";

?>

Output:

Hello escape "sequence" characters
PHP echo: printing variable value


PHP Operators

An Operator is a symbol that specifies an operation to be performed on the
operands.

Types of operators.

1. Arithmetic operators.

2. Assignment Operators

3. Incement and decrement Operators

4. Comparison operators

5. Conditional operators

6. Logical Operators.



7. Bitwise Operators.

, 8. String Operators.

1. Arithmetic operators.

These are used to perform basic arithmetic operations

There are five basic arithmetic operators.

+ (addition), - (subtraction), * (multiplication), / (division), % (modulus)

The operators are summarized in the following table.

Operator Name Example Result

+ Addition $x + $y Sum of $x and $y.

- Subtraction $x - $y Difference of $x and $y.

* Multiplication $x * $y Product of $x and $y.

/ Division $x / $y Quotient of $x and $y

% Modulus $x % $y Remainder of $x divided by $y.

Example:

<?php

$x=100;

$y=60;

echo "The sum of x and y is : ". ($x+$y) ."<br />";

echo "The difference between x and y is : ". ($x-$y) ."<br />";

echo "Multiplication of x and y : ". ($x*$y) ."<br />";

echo "Division of x and y : ". ($x/$y) ."<br />";

echo "Modulus of x and y : " . ($x%$y) ."<br />";

?>

Output:

The sum of x and y is : 160

The difference between x and y is : 40

Multiplication of x and y : 6000

Division of x and y : 1.6666666666667

Written for

Institution
Course

Document information

Uploaded on
April 19, 2023
Number of pages
52
Written in
2022/2023
Type
Class notes
Professor(s)
Chandramouli
Contains
All classes

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
manishnasani9966

Get to know the seller

Seller avatar
manishnasani9966 vaageswari college of engineering
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
3
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions