Introduction_to_PHP_and_Web_Development
Introduction_to_PHP_and_Web_Development
LANGUAGES
PHP in Detail & ASP.NET, Node.js Overview
1
Presented By : Kalpesh Chaudhari
Sr. Associate – COGNIZANT Technology Solution
TABLE OF CONTENTS
1. Introduction to PHP
2. PHP: General Syntax and Characteristics
3. Primitives, Operations, and Expressions
4. Output and Control Statements
5. Arrays and Functions
6. Pattern Matching
7. Form Handling in PHP
8. File Handling in PHP
9. Cookies and Session Tracking
10. Using MySQL with PHP
11. Introduction to ASP.NET
12. Overview of .NET Framework
13. Overview of C#
14. ASP.NET Controls
15. Web Services in ASP.NET
2
16. Overview of Node.js
17. Conclusion
INTRODUCTION TO PHP
Installation of PHP
Install a web server
Install PHP
Install a database, such as MySQL
The official PHP website (PHP.net) has installation instructions for PHP:
http://php.net/manual/en/install.php
3
INTRODUCTION TO PHP
PHP (Hypertext Preprocessor) is a server-side scripting language designed for web
development.
Key Features:
- Open-source
- Embedded in HTML
- Platform independent
- Supports a wide range of databases (MySQL, Oracle, MongoDB etc.)
-PHP scripts are executed on the server by processing hypertext.
-PHP files have extension ".php“.
-PHP can generate dynamic page content
-PHP can create, open, read, write, delete, and close files on the server
-PHP can collect form data
-PHP can send and receive cookies
-PHP can add, delete, modify data in your database
-PHP can be used to control user-access
4
-PHP can encrypt data
GENERAL SYNTACTIC
CHARACTERISTICS OF PHP
- Syntax: PHP code is enclosed in <?php ... ?> tags and ends with a semicolon.
- Variables: Declared using $ symbol (e.g., $variable) and dynamically typed.
- Comments: Single-line (//) and Multi-line (/* */)
5
PRIMITIVES, OPERATIONS, AND
EXPRESSIONS IN PHP
Primitives:
- String
Integer
Float (floating point numbers - also called double)
Boolean
Array
Object
NULL
Operators:
- Arithmetic: +, -, *, /, %
- Comparison: ==, !=, >, <
- Logical: &&, ||, !
Expressions:
- Combination of variables, operators, and values 6
OUTPUT IN PHP
Output Methods:
- echo: outputs one or more strings.
- print: outputs a single string.
Example: echo "Hello, World!";
echo and print are more or less the same. They are both
used to output data to the screen.
The differences are small: echo has no return value
while print has a return value of 1 so it can be used in
expressions. echo can take multiple parameters (although such
usage is rare) while print can take one argument. echo is marginally
faster than print.
7
CONTROL STATEMENTS IN PHP
Conditional Statements: if, else, elseif, switch.
if statement - executes some code if one condition is true
if...else statement - executes some code if a condition is true and
another code if that condition is false
if...elseif...else statement - executes different codes for more than
two conditions
switch statement - selects one of many blocks of code to be
executed
Types of Arrays:
- Indexed Arrays: Arrays with a numeric index.
- Associative Arrays: Arrays with named keys.
- Multidimensional Arrays: Arrays containing one or more arrays.
9
FUNCTIONS IN PHP
The real power of PHP comes from its functions. PHP has
more than 1000 built-in functions, and in addition you can create
your own custom functions.
10
PATTERN MATCHING IN PHP
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.
11
FORM HANDLING IN PHP
Form Methods:
- GET and POST methods
$_GET and $_POST Superglobals:
- Used to collect form data after submitting.
Example:
<form method="post" action="process.php">
<input type="text" name="username">
<input type="submit">
</form>
In process.php
$name = $_POST[username '];
echo $name;
12
FILE HANDLING IN PHP
File handling is an important part of any web application. You often need to open and
process a file for different tasks.
PHP has several functions for creating, reading, uploading, and editing files.
13
COOKIES IN PHP
A cookie is often used to identify a user. A cookie is a small file that the
server embeds on the user's computer. Each time the same computer requests a page
with a browser, it will send the cookie too. With PHP, you can both create and retrieve
cookie values.
14
SESSION TRACKING IN PHP
When you work with an application, you open it, do some changes, and
then you close it. This is much like a Session. The computer knows who you are. It
knows when you start the application and when you end. But on the internet there is
one problem: the web server does not know who you are or what you do, because the
HTTP address doesn't maintain state.
Session variables solve this problem by storing user information to be
used across multiple pages (e.g. username, favorite color, etc). By default, session
variables last until the user closes the browser.
So; Session variables hold information about one single user, and are
available to all pages in one application.
15
DIFFERENCE IN SESSION AND COOKIES
Cookies Session
Cookies are client-side files on a local Sessions are server-side files that
computer that hold user information. contain user data.
Cookies end on the lifetime set by When the user quits the browser or
the user. logs out of the programmed, the
session is over.
16
USING MYSQL WITH PHP
With PHP, you can connect to and manipulate databases.
MySQL is the most popular database system used with PHP.
17
USING MYSQL WITH PHP
Connection :
Connecting to MySQL: mysqli_connect()
Executing Queries: mysqli_query()
Example:
$conn = mysqli_connect("localhost", "username", "password");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$result = mysqli_query($conn, "SELECT * FROM users");
18
WAP AND WML
WAP stands for “Wireless Application Protocol”.
WML stands for “Wireless Markup Language”.
19
WAP AND WML
When it comes to actual use, WAP works as follows :
The user selects an option on their mobile device that has a URL with Wireless
Markup language (WML) content assigned to it.
The phone sends the URL request via the phone network to a WAP gateway using the
binary encoded WAP protocol.
The gateway translates this WAP request into a conventional HTTP request for the
specified URL and sends it on to the Internet.
The appropriate Web server picks up the HTTP request.
The server processes the request just as it would any other request. If the URL refers
to a static WML file, the server delivers it. If a CGI script is requested, it is processed
and the content returned as usual.
The Web server adds the HTTP header to the WML content and returns it to the
gateway.
The WAP gateway compiles the WML into binary form.
The gateway then sends the WML response back to the phone.
The phone receives the WML via the WAP protocol.
The micro-browser processes the WML and displays the content on the screen.
20
WAP AND WML
WML : WML scripting language is used to design applications that are sent over
wireless devices such as mobile phones. This language takes care of the small screen
and the low bandwidth of transmission. WML is an application of XML, which is
defined in a document-type definition.
Encoding WML is one of the tasks performed by the WAP
Gateway/Proxy.
21
OVERVIEW OF .NET FRAMEWORK
The .NET Framework is a software development framework developed by Microsoft
that provides a runtime environment and a set of libraries and tools for building and
running applications for Web, Desktop, Mobile and Gaming.
The .NET Framework includes two main components: the Common Language
Runtime (CLR) and the .NET Framework Class Library. The CLR is responsible for
managing the execution of code written in any of the supported languages, while the
class library provides a large set of pre-built functions and classes that can be used to
create a wide range of applications.
22
INTRODUCTION TO ASP.NET
ASP.NET is a web application framework developed by Microsoft for building
dynamic websites. ASP.NET is a web development platform, which provides a
programming model, a comprehensive software infrastructure and various services
required to build up robust web applications for PC, as well as mobile devices.
Key Feature:
ASP.NET is used to produce interactive, data-driven web applications over the
internet.
The life cycle phases are:
Initialization
Instantiation of the controls on the page
Restoration and maintenance of the state
Execution of the event handler codes
Page rendering
23
OVERVIEW OF C#
C# is a modern, general-purpose, object-oriented programming language
developed by Microsoft and approved by European Computer Manufacturers
Association (ECMA).
C# Characteristics:
Strongly typed
It is a modern, general-purpose programming language
It is object oriented.
It is component oriented.
It is easy to learn.
It is a structured language.
It produces efficient programs.
It can be compiled on a variety of computer platforms.
It is a part of .Net Framework.
24
ASP.NET CONTROLS
Types :
HTML server controls
HTML server controls provide automatic state management and server-side events.
When the ASP.NET page is reposted, the HTML server controls keep their values.
Web server controls
Basic Web Controls
However, basic Web controls include additional methods,
events, and properties against which you can program.
Validation Controls
Validation controls are used to validate the values that are
entered into other controls of the page. Validation controls perform client-
side validation, server-side validation, or both.
List Controls
List controls are special Web server controls that support
binding to collections. You can use list controls to display rows of data.
Rich Controls
Rich controls are built with multiple HTML elements and contain rich
functionality. Examples of rich controls are the Calendar control and the AdRotator control.
25
ASP.NET CONTROLS
User controls
Often, you may want to reuse the user interface of your Web Form
without having to write any extra code. ASP.NET enables you to do this by
converting your Web Forms into user controls. User controls, which have
the.ascx file extension, can be used multiple times within a single Web Form.
To convert a Web Form into a user control, follow these steps:
Remove all <html>, <head>, <body>, and <form> tags.
If the @ Page directive appears in the page, change it to @ Control.
Include a className attribute in the @ Control directive so that the user control is typed
strongly when you instantiate it.
Give the control a descriptive file name, and change the file extension from .aspx to .ascx.
Custom controls
In addition to the built-in Web controls, ASP.NET also allows you to
create your own custom controls. It may be useful to develop custom controls if you
are faced with one of these scenarios:
You need to combine the functionality of two or more built-in Web controls.
You need to extend the functionality of a built-in control.
You need a control that is different than any of the controls that currently exist.
26
WEB SERVICES IN ASP.NET
A web service is a web application which is basically a class consisting of
methods that could be used by other applications. It also follows a code-behind
architecture such as the ASP.NET web pages, although it does not have a user
interface.
There are 2 mainly used types of Web services :
1> Rest – Json Data
2> SOAP – Xml Data
A web service file called Service.asmx and its code behind file, Service.cs is created
in the App_Code directory of the project.
Running the web service application gives a web service test page, which allows
testing the service methods.
Click on a method name, and check whether it runs properly.
27
OVERVIEW OF NODE.JS
Node.js is an open-source and cross-platform JavaScript runtime environment. It is a
popular tool for almost any kind of project!
A Node.js app runs in a single process, without creating a new thread for every
request. Node.js provides a set of asynchronous I/O primitives in its standard library
that prevent JavaScript code from blocking and generally, libraries in Node.js are
written using non-blocking paradigms, making blocking behavior the exception rather
than the norm.
Node.js has a unique advantage because millions of frontend developers that write
JavaScript for the browser are now able to write the server-side code in addition to the
client-side code without the need to learn a completely different language.
Node.js is used to build back-end services like APIs like Web App, Mobile App or
Web Server. A Web Server will open a file on the server and return the content to the
client. It’s used in production by large companies such
as Paypal, Uber, Netflix, Walmart, and so on.
As Node js is Javascript Runtine Environment so Using node we can work on
multiple javascript framework like Angular, react etc.
28
CONCLUSION
So in this session whatever languages we saw those all languages are Server Side
Scripting Language.
Using all these languages we can develop dynamic web application.
We can create web services using all these languages.
29
Thank You All !
30