0% found this document useful (0 votes)
7 views10 pages

WT 2

Uploaded by

Abhishek Gawade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

WT 2

Uploaded by

Abhishek Gawade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

1.VARIABLES: A variable in PHP is a without having to do anything special.

container used to store data from the The PHP superglobal variables are
user. PHP variables start with a dollar $GLOBALS, $_SERVER, $_REQUEST,
sign ($), followed by the variable name. $_POST, $_GET, $_FILES, $_ENV,
To declare a variable, you simply use $_COOKIE, and $_SESSION.
the dollar sign followed by the
3.FORMS: Forms are essential parts
variable's name and assign it a value.
in web development. Forms are used
PHP automatically have some variables
to communicate between users and
called predefined variables available
the server. Form is a way to get
anywhere in the program. They are
information of the user to the server
array variables. These variables are:
and let the server do something in
$_ENV, $_GET, $_POST, $_COOKIE, and
response to the user’s input. We use
$_SERVER, referred to as EGPCS.
form to register in a website, to login,
1.$_COOKIE: This global array
to send feedback, to place order
contains any cookie values passed as
online, to book ticket online etc. After
part of the request, where the keys of
submitting the form, the form is
the array are the names of the cookies.
processed by PHP on the server. In PHP
2.$_GET: This global array contains
the form parameters are available in
any parameters that are part of a GET
the $_GET and $_POST arrays. When
request, where the keys of the array
user submits a form then the form
are the names of the form parameters.
parameter is send to the server. Before
3.$_POST: This global array contains
sending the information, browser
any parameters that are part of a POST
encodes it using a scheme called URL
request, where the keys of the array
encoding.
are the names of the form parameters.
4.$_FILES: This global array contains 4.GET Method: The GET method
information about any uploaded files. sends the encoded user information
5.$_SERVER: This global array appended to the page request (to the
contains useful information about the URL).
web server, as described in the next
5.POST Method: The POST method
section. 6.$_ENV: This global array
transfers information via HTTP
contains the values of any environment
headers, not through the URL. The
variables, where the keys of the array
information is encoded as described in
are the names of the environment
case of GET method and put into a
variables.
header called QUERY_STRING.
2.Several predefined variables
6. Sticky Forms: In sticky forms the
in PHP are "superglobals", which
values entered by user remain
means that they are always accessible,
displayed with the form component, if
regardless of scope and we can access
we display the form after submit.
them from any function, class or file
For example: If we search Google
(http://www.google.com) for “PHP Servers can store any data they like
Cookbook”, the top of the results page there in the value field of the cookie
contains another search box, which (within limits), such as a unique code
already contains “PHP Cookbook”. To identifying the user, preferences, etc.
refine the search to “PHP Cookbook PHP cookie is a small piece of
from O’Reilly”, we can simply add the information which is stored at client
extra keywords. browser. It is used to recognize the
user. Cookie is created at server side
7. File Uploads: In PHP to handle file
and saved to client browser. Each time
uploads, $_FILES array is used. The
when client sends request to the
elements of the $_FILES array gives
server, cookie is embedded with
information about the uploaded file.
request. Such way, cookie can be
The keys are: 1. name: The name
received at the server side.
of the file, as supplied by the browser.
$_FILE[‘filename’][‘name’] 2.
Type:The type of the uploaded file.
For example, image/jpeg.
$_FILE[‘filename’][‘type’] 3. Size: The
size of the uploaded file (in bytes). If 9. Sessions: A session can be
the user attempted to upload a file defined as "a series of related
that was too large, the size is reported interactions between a single client
as 0. $_FILE[‘filename’][‘size’] and the web server, which takes place
4.tmp_name: The name of the over a period of time". Sessions allow
temporary file on the server that holds you to store data in the web server
the uploaded file. If the user that associated with a session ID. Once
attempted to upload a file that was too you create a session, PHP sends a
large, the name is reported as "none". cookie that contains the session ID to
$_FILE[‘filename’][‘tmp_name’] the web browser. In the subsequent
5.Error: The error code resulting from requests, the web browser sends the
the uploaded file. $_FILE[‘filename’] session ID cookie back to the web
[‘error’] server so that PHP can retrieve the
data based on the session ID and make
8.Cookies: A cookie is a small piece
the data available in your script.
of data in the form of a name-value
Session provides a way to preserve
pair that is sent by a Web server and
certain data across subsequent
stored by the browser on the client
accesses. This enables us to build more
machine. This information is used by
customized applications.
the application running on the server
side to customize the web page 10.PHP ERROR HANDLING: Error
according to the past history of handling is the important part of any
transactions from that client machine. program. While creating PHP scripts
the errors need to be handled. If your
code lacks of error checking, your developed by an organization called
program may be open to security risks. the World Wide Web Consortium
Error handling is the process of (W3C) and is available as an open
catching errors raised by your program standard. 3.XML carries the data, does
and then taking appropriate action. not present it: XML allows you to store
the data irrespective of how it will be
11. Creating a Custom Error
presented.
Handler: In PHP we can define your
own error handler function to handle 14.XML DOCUMENT
any error. Creating a custom error STRUCTURE: XML document is a
handler is quite simple. We simply well - formed and valid document. A
create a special function that can be well - formed XML document follows
called when an error occurs in PHP. To the basic XML syntax rules, and a valid
create custom error handler first use document also follows the rules which
the library function are defined in a DTD or an XML
set_error_handler(). This function sets schema. In other words, 1.All XML
a user-defined error handler function. documents must be well-
Syntax: mixed set_error_handler formed: A well - formed XML
(callable $error_handler[, int document uses correct XML syntax.
$error_types = E_ALL | E_STRICT]) 2.An XML document can also
be valid: A well - formed document
12.Trigger an Error: In a script
does not need to be valid, but a valid
where users can input data it is useful
document must be well - formed.
to trigger errors when an illegal input
occurs. In PHP, this is done by the 15.CDATA Sections: The term
trigger_error() function. CDATA means, Character Data. CDATA
are defined as, blocks of text that are
13.WHAT IS XML? : The XML
not parsed by the parser, but are
(eXtensible Markup Language) lets us
otherwise recognized as markup.
to create text documents that can hold
Syntax: <![CDATA[
data in a structured way. Actually XML
Characters with markup
is a means of storing structured data.
]]>
The XML - based language can be
The above syntax is composed of three
placed online and any application can
sections: CDATA Start section:
read and write it. So, two applications
CDATA begins with the delimiter
that know nothing about each other
delimiter. CDATA End section:
can still exchange data.
CDATA section ends with ]]> delimiter.
Characteristics of XML: 1.XML is
CData section: Characters between
extensible: XML allows you to create
these two delimiters are interpreted as
your own self-descriptive tags, or
characters, and not as markup. This
language, that suits your application.
section may contain markup character
2.XML is a public standard: XML was
(<,>, and &), but they are ignored by the various nodes (elements,
the XML processor. attributes, and so on) of an XML
document as a tree of objects. Then
16.XML parser: XML parser is used
the tree can be traversed and various
to create, read and manipulate an XML
nodes can be accessed. By using
document. In PHP there are two major
various DOM class methods you can
types of XML parsers: 1.Tree-Based
also change any of these nodes, and
Parsers: Tree-based parser
even create a new DOM document
transforms the XML document into a
from scratch.
Tree structure, and then you can
access the tree elements individually. 19.Creating an XML Document
Example of tree based parsers: using the DOM: To create a node,
SimpleXML and DOM. 2.Event- you call various methods of the
Based Parsers: View an XML DOMDocument class. Some useful
document as a series of events. When methods are: 1. createElement(name
a specific event occurs, it calls a [, value ]): Creates an element node
function to handle it. called name and optionally appends a
text node to it containing value. 2.
17.Creating a New Parser: Step
createTextNode(content): Creates a
1 : Create a new parser resource by
text node that contains content. 3.
calling the xml_parser_create()
createCDATASection(data): Creates a
function. Step 2: Create two event
character data node that contains data.
handler functions to handle the start
4. createComment(data): Creates a
and end of an XML element, then
comment node that contains data. 5.
register these functions with the parser
appendChild(): Appends a child
using the xml_set_element_handler()
element to its root element. 6.
function. Step 3: Create another
setAttribute(): Add attributes to
event handler function to handle any
element nodes. 7. createAttribute():
character (text) data that may be found
Create new attribute. 8. saveXML():
inside an element, and register this
Converts the DOMDocument object
function with the parser using
into string.
xml_set_character_data_handler() .
Step 4: Parse the XML document by 20.SimpleXML: With SimpleXML, all
calling the xml_parse() function, the elements in an XML document are
passing in the parser and the XML represented as a tree of
string to parse. Step 5: Finally, SimpleXMLElement objects. Any given
destroy the parser resource, if it is no element’s children are available as
longer needed, by calling properties of the element’s
xml_parser_free(). SimpleXMLElement object. For
example, if $parent is a
18.The Document Object Model
SimpleXMLElement object
(DOC): DOM is a way of expressing
representing an element that has a 1.Lightweight, 2. DOM Manipulation,
child element called child, we can 3.Event Handling, 4.Latest Technology,
access that child element’s text value 5.AJAX Support, 6.Animations, 7.Cross
directly with: $value = $parent- > child; Browser Support. Advantages: 1.
Simple and Easy, 2.Cross browser
21.JAVASCRIPT: JavaScript is a
support: jQuery support all modern
scripting language designed primarily
web-browser. 3.Lightweight: jQuery is
for adding interactivity to Web pages
very lightweight library. 4.CSS
and creating Web applications.
Manipulation, 6.Extendibility.
Features: 1.JavaScript is an object-
Disadvantages: 1.jQuery Not built
based scripting language. 2.It is light
for larger and complex applications.
weighted. 3.JavaScript is a scripting
2.For larger and more complicated
language and it is not java. 4.JavaScript
applications we will need to extend
is interpreter based scripting language.
way beyond core with additional
5.JavaScript gives HTML designers a
libraries and Plugins.
programming tool. 6.JavaScript can put
dynamic text into an HTML page. 23.JavaScript Data Types: 1.
7.JavaScript can react to event. Primitive: String, Number, Boolean,
8.JavaScript can read and write HTML Undefined, Null. 2.Non-primitive:
document. 9.JavaScript can be used to Object, Array, RegExp.
validate data. Advantages: 1.Less
24.Variables: Variables are
server interaction, 2.Immediate
"containers" for storing information.
feedback to the visitors, 3.Increased
JavaScript variables are used to hold
interactivity, 4.Richer interfaces,
values (a = 5) or expressions (x = y + z)
5.Speed, 6.Simplicity, 7.Versatility,
in them. Syntax: var variable_name =
8.Server load. Disadvantages:
value;
1.Client-side JavaScript does not allow
the reading or writing of files. 25.Loops: It is often the case that we
3.JavaScript does not have any want to do something fixed number of
multithreading or multiprocessing times or until a particular condition has
capabilities. 4.Security. been met. In JavaScript, this repetitive
operation is done using loops. Loops
22.JQuery: jQuery is a JavaScript
can execute a block of code a number
library designed to simplify HTML DOM
of times. JavaScript supports following
tree traversal and manipulation as well
kinds of loops: 1.for, 2. for/in, 3. While,
as event handling, CSS animation and
4. do/while.
Ajax. The main purpose of jQuery is to
provide an easy way to use JavaScript 26.for Loop: The ‘for’ loop is the
on your website to make it more most compact form of looping. It
interactive and attractive. It is also includes the following three important
used to add animation. Features: parts: 1.The loop initialization where
we initialize our counter to a starting
value. The initialization statement is particular case. The break statement
executed before the loop begins. 2.The was used to "jump out" of a switch()
test statement which will test if a given statement. The break statement can
condition is true or not. If the also be used to jump out of a loop.
condition is true, then the code given Syntax: break;
inside the loop will be executed,
continue Statement: The
otherwise the control will come out of
continue statement breaks one
the loop. 3.The iteration statement
iteration (in the loop), if a specified
where you can increase or decrease
condition occurs, and continues with
your counter. Syntax: for(initialize;
the next iteration in the loop. Syntax:
condition; increment) { // execute
continue;
statements; }
31.JS FUNCTIONS: Like any other
27.for/in Loop: JavaScript for/in
advance programming language,
statement loops through the
JavaScript also supports all the features
properties of an object. Syntax:
necessary to write modular code using
for(variablename in object) { //
functions. A function is a block of code
statement or block to execute … } .In
that will be executed when "someone"
each iteration, one property from
calls it. Function is a block of
object is assigned to variablename and
statements that performs certain task.
this loop continues till all the
Functions are of two types’ pre-
properties of the object are exhausted.
defined/built-in functions and user-
28.while Loop: The purpose of a defined functions. 1. Built-in functions
while loop is to execute a statement or are the functions that are already
code block repeatedly as long as an defined in the JavaScript. Examples are
expression is true. Once, the write(), alert(), prompt() etc. 2. User-
expression becomes false, the loop defined functions are defined by a
terminates. Syntax: initialize; while user. Sometimes, this functions are
(condition) { // execute statement; simple, and sometimes they are quite
increment; } complex.
29.do/while Loop: Sometimes, we 32. JAVASCRIPT HTML DOM
want some statements to be executed EVENTS: A Document object
atleast once even if the condition is represents the HTML document that is
false for the first time. To do this we displayed in that window. The
use a do-while loop. Syntax: do { // Document object has various
Statements to be executed; }while properties that refer to other objects
(expression); which allow access to and modification
of document content. The way that
30. Loop Control Statements:
document content is accessed and
break Statement: The break
modified is called the Document
statement indicates the end of that
Object Model, or DOM. JavaScript Syntax: confirm("Message").
DOM Objects: 1.The anchors Array, 3.Prompt Box: A prompt box is often
2. The button Object, 3. The checkbox used if you want the user to input a
Object, 4. The Document Object, 5. The value before entering a page. Syntax:
form Object, 6. The frame Object, 7. prompt("sometext","defaultvalue").
The hidden Object.
34.JQUERY SELECTORS: jQuery
33.EVENT HANDLING IN selectors are one of the most
JAVASCRIPT: When JavaScript code is important parts of the jQuery library.
included in HTML, js react over these jQuery Selectors are used to select and
events and allow the execution. This manipulate HTML elements. jQuery
process of reacting over the events is selectors are used to "find" (or select)
called Event Handling. 1.Events: HTML elements based on their name,
JavaScript-enabled Web pages are id, classes, types, attributes, values of
typically event driven. Events are attributes and much more.
actions that occur on the webpage.
35.DOM Manipulation Methods:
Events are signals generated when
Following are the methods which we
specific action occurs. 2.Event
can use to manipulate DOM elements:
Handler: Event handlers execute
1.The after(content) method insert
JavaScript code to respond to events
content after each of the matched
whenever they occur.
elements. 2.The append(content)
34.JS STRINGS: The JavaScript string method append content to the inside
is an object that represents a sequence of every matched element. 3.The
of characters. The string object is used appendTo(selector) method append all
for storing and manipulating text. of the matched elements to another,
specified, set of elements. 4.The
35.lists methods of string in JS:
before(content) method inserts
1.charAt(), 2.charCodeAt(), 3.concat(),
content before each of the matched
4.indexOf(), 5.lastIndexOf(),
elements. 5.The clone(bool) method
6.localeCompare(), 7.match(),
matched DOM elements and all their
8.replace(), 9.search(), 10.slice(),
event handlers, and select the clones.
11.split().
36.AJAX: AJAX (Asynchronous
35. JS POP-UP BOXES: 1.Alert
JavaScript And XML) is a set of web
Box: An alert box is often used if we
development techniques that uses
want to make sure information comes
various web technologies on the client-
through to the user. When an alert box
side to create asynchronous web
pops up, the user will have to click
applications. Ajax is a new technique
"OK" to proceed. Syntax: alert("Alert
for creating better, faster, and more
Message"). 2.Confirm Box: A
interactive web applications with the
confirm box is often used if you want
help of XML, HTML, CSS, and
the user to verify or accept something.
JavaScript. Ajax is not a technology but
group of inter-related technologies.
Advantages of Ajax: 1.Better
interactivity: Ajax allows easier and
quicker interaction between user and
website as whole pages are not
reloaded for content to be displayed.
2.Easier navigation, 3.Compact: With
Ajax, several multipurpose applications
and features can be handled using a
single web page. It just require a few
lines of code. 4.Backed by reputed
brands. Disadvantages: 1.Built on
JavaScript: A percentage of website
38.Understanding
surfers prefer to turn JavaScript
XMLHttpRequest: The
functionality off on their browser
XMLHttpRequest object is the key to
making the Ajax application useless.
Ajax. The XMLHttpRequest is used for
2.Browser support: All browsers do not
asynchronous communication between
support JavaScript or XMLHttpRequest
client and server. The XMLHttpRequest
object. 3.Security and User privacy.
object can send HTTP request, and
applications using Ajax include
receive responses. The
Google Maps, Gmail, Youtube, and
XMLHttpRequest object transfer the
Facebook etc.
XML and other text data to and from
37.Asynchronous (Ajax Web- the Web server by using HTTP.
Application Model): The
intermediary layer (i.e. Ajax Engine) is 39.AJAX-PHP FRAMEWORK: The
introduced between the user and the PHP-frameworks gives different ways
Web server. The Web page sends its to affect the client view in both
requests using JavaScript. The request template based view (uses
is done asynchronously, meaning that technologies like JSP, ASP and RHTML)
code execution does not wait for and server-side technologies (like
response. The server response ASP.NET and JSP). This functionality
comprises of data and not the becomes popular in the server-side
presentation. The Ajax engine can Ajax packages, because it automatically
understand and interpret the data. create JavaScript code for us. There are
Most of the page does not change, various PHP frameworks available, like
only parts of the page that need to Ajax Core, CakePHP, Xajax, Sajax, XOAD,
change are updated. Zephyr, Feather Ajax 1.1 and
Tigermouse to integrate Ajax with PHP.
These frameworks support Model,
View and Controller (MVC) 43.MVC FRAMEWORK: CodeIgniter
architecture. They reduces the writing is based on the Model-View-Controller
of same code and common function (MVC) development architecture. MVC
repeatedly. standards for Model-View-Controller.
MVC is a software design pattern
40.PERFORMING AJAX
which separates application logic from
VALIDATION: The validation may
its presentation which dictates the
done for checking integer, email id or
clear separation of concerns. 1.
phone number etc. The first page for
Model: The MVC model represents
application displays the text field to
application's data structures. Model
enter the username. It has JavaScript
classes interface with database and
code to create the XMLHttpRequest
contain functionality for retrieving,
object. The validate method sends
inserting and updating information in
request to validate the PHP page with
the database. 2. View: It is
parameter name.
responsible for data presentation. A
41.CODEIGNITER: CodeIgniter is an view contains information presented to
open-source software rapid an end user and on most occasions is
development web framework, for use normally a Web page. 3. Controller:
in building dynamic web sites with PHP. It is an interface between a model and
CodeIgniter is a PHP MVC framework a view. In MVC all user requests are
used for developing Web applications. handled by a controller. It coordinates
CodeIgniter provides out of the box the activities between the model and
libraries for connecting to the database the view.
and performing various operations like
44.Controllers in MVC: A
sending emails, uploading files,
controller in CodeIgniter is a simple
managing sessions, etc. Features:
class file. As the name suggests,
1.MVC Architecture, 2.Extendable,
controller controls the whole
3.Loosely Coupled, 4.Small Footprint,
application by URI. In CodeIgniter, a
5.Excellent Documentation,
Controller is simply a class file that is
6.Application specific Built-in
named in a way that it can be
Components, 7.Blazing Fast.
associated with a URI.
42.INSTALLING CODEIGNITER:
45.CODEIGNITER LIBRARIES:
Step 1: Download CodeIgniter
CodeIgniter provide a rich set of
Framework, Step 2: Unzip CodeIgniter-
libraries. Libraries are an essential part
4.1.4.zip File, Step 3: Create a new
of CodeIgniter as it increases the
directory, Step 4: Open the contents of
developing speed of an application. It
CodeIgniter-4.1.4, Step 5: Open the
is located in the system/library.
Terminal and Run the following
CodeIgniter libraries provides a rich set
command. Step 6: Open the URL.
of libraries, which indirectly increase
the speed of developing an application.
46.COOKIES MANAGEMENT:
Cookie is a small piece of data sent
from Web server to store on
client’s/browser’s computer.
CodeIgniter has one helper called
“Cookie Helper” for cookie
management. The Cookie Helper
contains functions that assist in
working with cookies.
47.WORKING WITH DATABASES:
A database is an organized collection of
data, so that it can be easily accessed
and managed. Like any other
framework, we need to interact with
the database very often and
CodeIgniter makes this job very simple
and easy for us. CodeIgniter provides
rich set of functionalities to interact
with database. The database of the site
can be configured in
application/config/database.php file. In
this section, we will understand how
the CRUD (Create, Read, Update,
Delete) functions work with
CodeIgniter.

You might also like