際際滷

際際滷Share a Scribd company logo
UNIT 4- PHP & XML
CS8651 - INTERNET
PROGRAMMING
 An introduction to PHP: PHP- Using PHP- Variables- Program
control- Built-in functions- Form Validation- Regular Expressions -
File handling  Cookies - Connecting to Database.
 XML: Basic XML- Document Type Definition- XML Schema
DOM and Presenting XML, XML
 Parsers and Validation, XSL and XSLT Transformation, News Feed
(RSS and ATOM).
UNIT IV: SYLLABUS
AN INTRODUCTION TO PHP
 PHP is an open-source, interpreted, and object-oriented scripting
language that can be executed at the server-side.
 PHP is well suited for web development.
 PHP stands for Hypertext Pre-processor.
 PHP is an interpreted language, i.e., there is no need for
compilation.
 PHP is faster than other scripting languages, for example, ASP and
JSP.
PHP
 PHP is a server-side scripting language, which is used to manage
the dynamic content of the website.
 PHP can be embedded into HTML.
 PHP is an object-oriented language.
 PHP is an open-source scripting language.
 PHP is simple and easy to learn language.
PHP
 PHP is a server-side scripting language, which is used to design the
dynamic web applications with MySQL database.
 It handles dynamic content, database as well as session tracking
for the website.
 You can create sessions in PHP.
 It can access cookies variable and also set cookies.
 It helps to encrypt the data and apply validation.
 PHP supports several protocols such as HTTP, POP3, SNMP,
LDAP, IMAP, and many more.
WHY USE PHP?
 Using PHP language, you can control the user to access some
pages of your website.
 As PHP is easy to install and set up, this is the main reason why
PHP is the best language to learn.
 PHP can handle the forms, such as - collect the data from users
using forms, save it into the database, and return useful
information to the user. For example - Registration form.
WHY USE PHP?
PHP FEATURES
 How to install XAMPP server on windows -
https://www.apachefriends.org/download.html
INSTALL PHP
 After downloading XAMPP, double click on the downloaded file
and allow XAMPP to make changes in your system. A window will
pop-up, where you have to click on the Next button.
INSTALL PHP
 XAMPP is ready to use. Start the Apache server and MySQL and
run the php program on the localhost.
INSTALL PHP
 If no error is shown, then XAMPP is running successfully.
INSTALL PHP
 PHP programs can be written on any editor, such as - Notepad,
Notepad++, Dreamweaver, etc.
 These programs save with .php extension, i.e., filename.php inside
the htdocs folder.
 Step 1: Create a simple PHP program like hello world.
<!DOCTYPE html>
<html>
<body>
<h1>PHP</h1>
<?php
echo "Hello World";
?>
</body></html>
RUN PHP CODE IN XAMPP
 Step 2: Save the file with hello.php name in the htdocs folder,
which resides inside the xampp folder.
 Step 3: Run the XAMPP server and start the Apache and MySQL.
 Step 4: Now, open the web browser and type localhost
 http://localhost/hello.php on your browser window.
RUN PHP CODE IN XAMPP
 In PHP, keyword (e.g., echo, if, else, while), functions, user-
defined functions, classes are not case-sensitive.
 However, all variable names are case-sensitive.
PHP - CASE SENSITIVE
 A variable is a name given to a memory location that stores data at
runtime.
 The scope of a variable determines its visibility.
 The rules followed when creating variables in PHP
 All variable names must start with the dollar sign.
 Variable names are case sensitive;
 All variables names must start with a letter follow other
characters
 Variable names must not contain any spaces
PHP - VARIABLE
ARITHMETIC OPERATORS
ASSIGNMENT OPERATORS
COMPARISON OPERATORS
LOGICAL OPERATORS
 A function is a block of statements that can be used repeatedly in a
program.
 A function is a self-contained block of code that performs a
specific task.
 A function is a piece of code which takes one or more input in the
form of parameter and does some processing and returns a value.
PHP FUNCTIONS
 Better code organization
 PHP functions allow us to group blocks of related code that
perform a specific task together.
 Reusability
 Once defined, a function can be called by a number of scripts in
our PHP files. This saves us time of reinventing the wheel when
we want to perform some routine tasks such as connecting to
the database
 Easy maintenance
 Updates to the system only need to be made in one place.
WHY USE PHP FUNCTIONS?
 An HTML form contains various input fields such as text box,
checkbox, radio buttons, submit button, and checklist, etc.
 These input fields need to be validated, which ensures that the user
has entered information in all the required fields and also validates
that the information provided by the user is valid and correct.
 There are two types of validation are available in PHP.
 Client-Side Validation  Validation is performed on the client
machine web browsers.
 Server Side Validation  After submitted by data, the data has sent
to a server and perform validation checks in server machine.
FORM VALIDATION
 The things need to be validate are as follows:
 Empty String
 Validate String
 Validate Numbers
 Validate Email
 Validate URL
 Input length
FORM VALIDATION
 A regular expression is a sequence of characters that forms a
search pattern.
 When you search for data in a text, you can use this search pattern
to describe what you are searching for.
 A regular expression can be a single character, or a more
complicated pattern.
 Regular expressions can be used to perform all types of text search
and text replace operations.
REGULAR EXPRESSION
 In PHP, regular expressions are strings composed of delimiters, a
pattern and optional modifiers.
 In the example above, / is the delimiter, w3schools is
the pattern that is being searched for, and i is a modifier that
makes the search case-insensitive.
REGULAR EXPRESSION - SYNTAX
 Modifiers can change how a search is performed.
REGULAR EXPRESSION - MODIFIERS
 PHP supports file handling which is used to read, write and append
data to the file.
 Basic file handling steps
 Opening a file fopen()
 Reading a file fclose()
 Writing a file fread()
 Closing a file fwrite()
 Delete File unlink()
FILE HANDLING
 PHP fopen() function is used to open file or URL and returns
resource.
 The fopen() function accepts two arguments: $filename and
$mode.
 The $filename represents the file to be opended and $mode
represents the file mode for example read-only, read-write, write-
only etc.
fopen()
Modes Description
r Open a file for read only. File pointer starts at the beginning of the file
w Open a file for write only. Erases the contents of the file or creates a new file
if it doesn't exist. File pointer starts at the beginning of the file
a Open a file for write only. The existing data in file is preserved. File pointer
starts at the end of the file. Creates a new file if the file doesn't exist
x Creates a new file for write only. Returns FALSE and an error if file already
exists
r+ Open a file for read/write. File pointer starts at the beginning of the file
w+ Open a file for read/write. Erases the contents of the file or creates a new file
if it doesn't exist. File pointer starts at the beginning of the file
a+ Open a file for read/write. The existing data in file is preserved. File pointer
starts at the end of the file. Creates a new file if the file doesn't exist
x+ Creates a new file for read/write. Returns FALSE and an error if file already
exists
fopen()
FILE OPERATIONS
 The fread() function reads from an open file.
 The fclose() function is used to close an open file.
 The fgets() function is used to read a single line from a file.
 The feof() function checks if the "end-of-file" (EOF) has been
reached.
 The fgetc() function is used to read a single character from a file.
 The fwrite() function is used to write to a file.
COOKIES
 A cookie is a small file with the maximum size of 4KB that the
web server stores on the client computer.
 They are typically used to keeping track of information such as a
username that the site can retrieve to personalize the page when
the user visits the website next time.
 A cookie can only be read from the domain that it has been issued
from.
Create Cookies With PHP
 A cookie is created with the setcookie() function.
 The value of the cookie can be retrieved using the global variable
$_COOKIE.
 isset() function is used to find out if the cookie is set.
 The setcookie() function must appear before the <html> tag.
 To delete a cookie, use the setcookie() function with an
expiration date in the past.
 Check whether cookies enabled or not!!!!
DATABASE CONNECTIVITY
 In PHP, we can connect to the database using XAMPP web server
by using "localhost/phpmyadmin".
 Open XAMPP and start running Apache, MySQL
DATABASE CONNECTIVITY
 Now open PHP file and write PHP code to create database and a
table in your database.
 Save the file as data.php in htdocs folder under XAMPP folder.
 Then open web browser and type localhost/data.php. Finally the
database is created and connected to PHP.
An introduction to PHP : PHP and Using PHP, Variables Program control and Built-in functions.pptx
An introduction to PHP : PHP and Using PHP, Variables Program control and Built-in functions.pptx
An introduction to PHP : PHP and Using PHP, Variables Program control and Built-in functions.pptx
An introduction to PHP : PHP and Using PHP, Variables Program control and Built-in functions.pptx
XML
 Xml (eXtensible Markup Language) is a mark up language.
 XML is designed to store and transport data.
 XML is not a replacement for HTML.
 XML is designed to be self-descriptive.
 XML is designed to carry data, not to display data.
 XML tags are not predefined. You must define your own tags.
 XML is platform independent and language independent.
XML FEATURES
 XML is widely used in the era of web development. It is also used
to simplify data storage and data sharing.
 The main features or advantages of XML are given below.
 XML separates data from HTML
 XML simplifies data sharing
 XML simplifies data transport
 XML simplifies Platform change
 XML increases data availability
 XML can be used to create new internet languages
DIFFERENCES BETWEEN XML AND HTML
 .
EXAMPLE
DTD
 DTD stands for Document Type Definition.
 It defines the legal building blocks of an XML document.
 It is used to define document structure with a list of legal elements
and attributes.
 Its main purpose is to define the structure of an XML document.
 It contains a list of legal elements and define the structure with the
help of them.
 Before proceeding with XML DTD, you must check the
validation. An XML document is called "well-formed" if it
contains the correct syntax.
AN INTERNAL DTD DECLARATION
 If the DTD is declared inside the XML file, it must be wrapped
inside the <!DOCTYPE> definition:
AN EXTERNAL DTD DECLARATION
 If the DTD is declared in an external file, the <!DOCTYPE>
definition must contain a reference to the DTD file:
DTD - XML BUILDING BLOCKS
 All XML documents are made up by the following building
blocks:
 Elements : main building blocks of both XML and HTML
documents
 Attributes : provide extra information about elements
 Entities : expanded when a document is parsed by an XML
parser
 PCDATA : parsed character data
 CDATA : character data
XML PARSERS
 An XML parser is a software library or package that provides
interfaces for client applications to work with an XML document.
 The XML Parser is designed to read the XML and create a way for
programs to use XML.
 XML parser validates the document and check that the document
is well formatted.
XML DOM
 DOM is an acronym stands for Document Object Model.
 It defines a standard way to access and manipulate documents.
 Document Object Model (DOM) is a programming API for HTML
and XML documents.
 It defines the logical structure of documents and the way a
document is accessed and manipulated.
 XML DOM defines a standard way to access and manipulate XML
documents.
XML DOM
XML DOM

More Related Content

Similar to An introduction to PHP : PHP and Using PHP, Variables Program control and Built-in functions.pptx (20)

PPT
KEY PERFORMANCE INDICATOR FOR ICT-UNIT (new)Lect_04c_Detailed_Self_Reading.ppt
SenzotaSemakuwa
PPTX
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
PPTX
php basic part one
jeweltutin
PPTX
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
PRIYADARSINIK3
PPTX
Files in php
sana mateen
PPTX
Web Application Development using PHP Chapter 1
Mohd Harris Ahmad Jaal
PPTX
Php unit i
BagavathiLakshmi
PPTX
PHP ITCS 323
Sleepy Head
PDF
Working with files (concepts/pseudocode/python)
FerryKemperman
PPTX
PHP language presentation
Annujj Agrawaal
PPT
Php
Ajay Kumar
PPTX
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
PedakotaPavankumar
PDF
Php training in bhubaneswar
litbbsr
PDF
Php training in bhubaneswar
litbbsr
PDF
Introduction to php
KIRAN KUMAR SILIVERI
PPTX
Introduction to PHP.pptx
MarianJRuben
PPT
Php basics
sagaroceanic11
PPTX
1. introduction to php and variable
NurAliaAqilaMuhalis
PDF
Php tutorial from_beginner_to_master
PrinceGuru MS
KEY PERFORMANCE INDICATOR FOR ICT-UNIT (new)Lect_04c_Detailed_Self_Reading.ppt
SenzotaSemakuwa
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
php basic part one
jeweltutin
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
PRIYADARSINIK3
Files in php
sana mateen
Web Application Development using PHP Chapter 1
Mohd Harris Ahmad Jaal
Php unit i
BagavathiLakshmi
PHP ITCS 323
Sleepy Head
Working with files (concepts/pseudocode/python)
FerryKemperman
PHP language presentation
Annujj Agrawaal
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
PedakotaPavankumar
Php training in bhubaneswar
litbbsr
Php training in bhubaneswar
litbbsr
Introduction to php
KIRAN KUMAR SILIVERI
Introduction to PHP.pptx
MarianJRuben
Php basics
sagaroceanic11
1. introduction to php and variable
NurAliaAqilaMuhalis
Php tutorial from_beginner_to_master
PrinceGuru MS

More from Vigneshkumar Ponnusamy (7)

PPTX
Importing Matplotlib - Line plots - Scatter plots Visualizing errors.pptx
Vigneshkumar Ponnusamy
PPTX
Cloud Service Management Capex vs Opex Shift.pptx
Vigneshkumar Ponnusamy
PPTX
Web Technologies Introduction to web technologies
Vigneshkumar Ponnusamy
PPTX
Fundamentals of Data Structures Unit 1.pptx
Vigneshkumar Ponnusamy
PPTX
CS8651 IP Unit 3.pptx
Vigneshkumar Ponnusamy
PPTX
IP Unit 2.pptx
Vigneshkumar Ponnusamy
PPTX
CS8651 Internet Programming - Basics of HTML, HTML5, CSS
Vigneshkumar Ponnusamy
Importing Matplotlib - Line plots - Scatter plots Visualizing errors.pptx
Vigneshkumar Ponnusamy
Cloud Service Management Capex vs Opex Shift.pptx
Vigneshkumar Ponnusamy
Web Technologies Introduction to web technologies
Vigneshkumar Ponnusamy
Fundamentals of Data Structures Unit 1.pptx
Vigneshkumar Ponnusamy
CS8651 IP Unit 3.pptx
Vigneshkumar Ponnusamy
IP Unit 2.pptx
Vigneshkumar Ponnusamy
CS8651 Internet Programming - Basics of HTML, HTML5, CSS
Vigneshkumar Ponnusamy
Ad

Recently uploaded (20)

PPTX
How Physics Enhances Our Quality of Life.pptx
AngeliqueTolentinoDe
PPTX
2025 Completing the Pre-SET Plan Form.pptx
mansk2
PPTX
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
PDF
VCE Literature Section A Exam Response Guide
jpinnuck
PPTX
Elo the HeroTHIS IS A STORY ABOUT A BOY WHO SAVED A LITTLE GOAT .pptx
JoyIPanos
PDF
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
PPTX
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
PDF
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
PDF
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
DOCX
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
PDF
COM and NET Component Services 1st Edition Juval L旦wy
kboqcyuw976
PDF
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
PDF
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
PPTX
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
PPTX
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
PPTX
Peer Teaching Observations During School Internship
AjayaMohanty7
PPTX
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
How Physics Enhances Our Quality of Life.pptx
AngeliqueTolentinoDe
2025 Completing the Pre-SET Plan Form.pptx
mansk2
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
VCE Literature Section A Exam Response Guide
jpinnuck
Elo the HeroTHIS IS A STORY ABOUT A BOY WHO SAVED A LITTLE GOAT .pptx
JoyIPanos
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
COM and NET Component Services 1st Edition Juval L旦wy
kboqcyuw976
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
Rapid Mathematics Assessment Score sheet for all Grade levels
DessaCletSantos
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
Peer Teaching Observations During School Internship
AjayaMohanty7
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
Ad

An introduction to PHP : PHP and Using PHP, Variables Program control and Built-in functions.pptx

  • 1. UNIT 4- PHP & XML CS8651 - INTERNET PROGRAMMING
  • 2. An introduction to PHP: PHP- Using PHP- Variables- Program control- Built-in functions- Form Validation- Regular Expressions - File handling Cookies - Connecting to Database. XML: Basic XML- Document Type Definition- XML Schema DOM and Presenting XML, XML Parsers and Validation, XSL and XSLT Transformation, News Feed (RSS and ATOM). UNIT IV: SYLLABUS
  • 4. PHP is an open-source, interpreted, and object-oriented scripting language that can be executed at the server-side. PHP is well suited for web development. PHP stands for Hypertext Pre-processor. PHP is an interpreted language, i.e., there is no need for compilation. PHP is faster than other scripting languages, for example, ASP and JSP. PHP
  • 5. PHP is a server-side scripting language, which is used to manage the dynamic content of the website. PHP can be embedded into HTML. PHP is an object-oriented language. PHP is an open-source scripting language. PHP is simple and easy to learn language. PHP
  • 6. PHP is a server-side scripting language, which is used to design the dynamic web applications with MySQL database. It handles dynamic content, database as well as session tracking for the website. You can create sessions in PHP. It can access cookies variable and also set cookies. It helps to encrypt the data and apply validation. PHP supports several protocols such as HTTP, POP3, SNMP, LDAP, IMAP, and many more. WHY USE PHP?
  • 7. Using PHP language, you can control the user to access some pages of your website. As PHP is easy to install and set up, this is the main reason why PHP is the best language to learn. PHP can handle the forms, such as - collect the data from users using forms, save it into the database, and return useful information to the user. For example - Registration form. WHY USE PHP?
  • 9. How to install XAMPP server on windows - https://www.apachefriends.org/download.html INSTALL PHP
  • 10. After downloading XAMPP, double click on the downloaded file and allow XAMPP to make changes in your system. A window will pop-up, where you have to click on the Next button. INSTALL PHP
  • 11. XAMPP is ready to use. Start the Apache server and MySQL and run the php program on the localhost. INSTALL PHP
  • 12. If no error is shown, then XAMPP is running successfully. INSTALL PHP
  • 13. PHP programs can be written on any editor, such as - Notepad, Notepad++, Dreamweaver, etc. These programs save with .php extension, i.e., filename.php inside the htdocs folder. Step 1: Create a simple PHP program like hello world. <!DOCTYPE html> <html> <body> <h1>PHP</h1> <?php echo "Hello World"; ?> </body></html> RUN PHP CODE IN XAMPP
  • 14. Step 2: Save the file with hello.php name in the htdocs folder, which resides inside the xampp folder. Step 3: Run the XAMPP server and start the Apache and MySQL. Step 4: Now, open the web browser and type localhost http://localhost/hello.php on your browser window. RUN PHP CODE IN XAMPP
  • 15. In PHP, keyword (e.g., echo, if, else, while), functions, user- defined functions, classes are not case-sensitive. However, all variable names are case-sensitive. PHP - CASE SENSITIVE
  • 16. A variable is a name given to a memory location that stores data at runtime. The scope of a variable determines its visibility. The rules followed when creating variables in PHP All variable names must start with the dollar sign. Variable names are case sensitive; All variables names must start with a letter follow other characters Variable names must not contain any spaces PHP - VARIABLE
  • 21. A function is a block of statements that can be used repeatedly in a program. A function is a self-contained block of code that performs a specific task. A function is a piece of code which takes one or more input in the form of parameter and does some processing and returns a value. PHP FUNCTIONS
  • 22. Better code organization PHP functions allow us to group blocks of related code that perform a specific task together. Reusability Once defined, a function can be called by a number of scripts in our PHP files. This saves us time of reinventing the wheel when we want to perform some routine tasks such as connecting to the database Easy maintenance Updates to the system only need to be made in one place. WHY USE PHP FUNCTIONS?
  • 23. An HTML form contains various input fields such as text box, checkbox, radio buttons, submit button, and checklist, etc. These input fields need to be validated, which ensures that the user has entered information in all the required fields and also validates that the information provided by the user is valid and correct. There are two types of validation are available in PHP. Client-Side Validation Validation is performed on the client machine web browsers. Server Side Validation After submitted by data, the data has sent to a server and perform validation checks in server machine. FORM VALIDATION
  • 24. The things need to be validate are as follows: Empty String Validate String Validate Numbers Validate Email Validate URL Input length FORM VALIDATION
  • 25. A regular expression is a sequence of characters that forms a search pattern. When you search for data in a text, you can use this search pattern to describe what you are searching for. A regular expression can be a single character, or a more complicated pattern. Regular expressions can be used to perform all types of text search and text replace operations. REGULAR EXPRESSION
  • 26. In PHP, regular expressions are strings composed of delimiters, a pattern and optional modifiers. In the example above, / is the delimiter, w3schools is the pattern that is being searched for, and i is a modifier that makes the search case-insensitive. REGULAR EXPRESSION - SYNTAX
  • 27. Modifiers can change how a search is performed. REGULAR EXPRESSION - MODIFIERS
  • 28. PHP supports file handling which is used to read, write and append data to the file. Basic file handling steps Opening a file fopen() Reading a file fclose() Writing a file fread() Closing a file fwrite() Delete File unlink() FILE HANDLING
  • 29. PHP fopen() function is used to open file or URL and returns resource. The fopen() function accepts two arguments: $filename and $mode. The $filename represents the file to be opended and $mode represents the file mode for example read-only, read-write, write- only etc. fopen()
  • 30. Modes Description r Open a file for read only. File pointer starts at the beginning of the file w Open a file for write only. Erases the contents of the file or creates a new file if it doesn't exist. File pointer starts at the beginning of the file a Open a file for write only. The existing data in file is preserved. File pointer starts at the end of the file. Creates a new file if the file doesn't exist x Creates a new file for write only. Returns FALSE and an error if file already exists r+ Open a file for read/write. File pointer starts at the beginning of the file w+ Open a file for read/write. Erases the contents of the file or creates a new file if it doesn't exist. File pointer starts at the beginning of the file a+ Open a file for read/write. The existing data in file is preserved. File pointer starts at the end of the file. Creates a new file if the file doesn't exist x+ Creates a new file for read/write. Returns FALSE and an error if file already exists fopen()
  • 31. FILE OPERATIONS The fread() function reads from an open file. The fclose() function is used to close an open file. The fgets() function is used to read a single line from a file. The feof() function checks if the "end-of-file" (EOF) has been reached. The fgetc() function is used to read a single character from a file. The fwrite() function is used to write to a file.
  • 32. COOKIES A cookie is a small file with the maximum size of 4KB that the web server stores on the client computer. They are typically used to keeping track of information such as a username that the site can retrieve to personalize the page when the user visits the website next time. A cookie can only be read from the domain that it has been issued from.
  • 33. Create Cookies With PHP A cookie is created with the setcookie() function. The value of the cookie can be retrieved using the global variable $_COOKIE. isset() function is used to find out if the cookie is set. The setcookie() function must appear before the <html> tag. To delete a cookie, use the setcookie() function with an expiration date in the past. Check whether cookies enabled or not!!!!
  • 34. DATABASE CONNECTIVITY In PHP, we can connect to the database using XAMPP web server by using "localhost/phpmyadmin". Open XAMPP and start running Apache, MySQL
  • 35. DATABASE CONNECTIVITY Now open PHP file and write PHP code to create database and a table in your database. Save the file as data.php in htdocs folder under XAMPP folder. Then open web browser and type localhost/data.php. Finally the database is created and connected to PHP.
  • 40. XML Xml (eXtensible Markup Language) is a mark up language. XML is designed to store and transport data. XML is not a replacement for HTML. XML is designed to be self-descriptive. XML is designed to carry data, not to display data. XML tags are not predefined. You must define your own tags. XML is platform independent and language independent.
  • 41. XML FEATURES XML is widely used in the era of web development. It is also used to simplify data storage and data sharing. The main features or advantages of XML are given below. XML separates data from HTML XML simplifies data sharing XML simplifies data transport XML simplifies Platform change XML increases data availability XML can be used to create new internet languages
  • 44. DTD DTD stands for Document Type Definition. It defines the legal building blocks of an XML document. It is used to define document structure with a list of legal elements and attributes. Its main purpose is to define the structure of an XML document. It contains a list of legal elements and define the structure with the help of them. Before proceeding with XML DTD, you must check the validation. An XML document is called "well-formed" if it contains the correct syntax.
  • 45. AN INTERNAL DTD DECLARATION If the DTD is declared inside the XML file, it must be wrapped inside the <!DOCTYPE> definition:
  • 46. AN EXTERNAL DTD DECLARATION If the DTD is declared in an external file, the <!DOCTYPE> definition must contain a reference to the DTD file:
  • 47. DTD - XML BUILDING BLOCKS All XML documents are made up by the following building blocks: Elements : main building blocks of both XML and HTML documents Attributes : provide extra information about elements Entities : expanded when a document is parsed by an XML parser PCDATA : parsed character data CDATA : character data
  • 48. XML PARSERS An XML parser is a software library or package that provides interfaces for client applications to work with an XML document. The XML Parser is designed to read the XML and create a way for programs to use XML. XML parser validates the document and check that the document is well formatted.
  • 49. XML DOM DOM is an acronym stands for Document Object Model. It defines a standard way to access and manipulate documents. Document Object Model (DOM) is a programming API for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated. XML DOM defines a standard way to access and manipulate XML documents.