You are on page 1of 2

Web Development through Open Source Technologies (PHP, MYSQL)

Q 5) What are the must learn OOPS concepts in PHP


 Class − This is a programmer-defined data type, which includes local functions as well as local data. You can
think of a class as a template for making many instances of the same kind (or class) of object.
 Object − An individual instance of the data structure defined by a class. You define a class once and then make
many objects that belong to it. Objects are also known as instance.
 Member Variable − These are the variables defined inside a class. This data will be invisible to the outside of the
class and can be accessed via member functions. These variables are called attribute of the object once an
object is created.
 Member function − These are the function defined inside a class and are used to access object data.
 Inheritance − When a class is defined by inheriting existing function of a parent class then it is called inheritance.
Here child class will inherit all or few member functions and variables of a parent class.
 Parent class − A class that is inherited from by another class. This is also called a base class or super class.
 Child Class − A class that inherits from another class. This is also called a subclass or derived class.
 Polymorphism − This is an object oriented concept where same function can be used for different purposes. For
example function name will remain same but it make take different number of arguments and can do different
task.
 Overloading − A type of polymorphism in which some or all of operators have different implementations
depending on the types of their arguments. Similarly functions can also be overloaded with different
implementation.
 Data Abstraction − Any representation of data in which the implementation details are hidden (abstracted).
 Encapsulation − refers to a concept where we encapsulate all the data and member functions together to form
an object.
 Constructor − refers to a special type of function which will be called automatically whenever there is an object
formation from a class.
 Destructor − refers to a special type of function which will be called automatically whenever an object is deleted
or goes out of scope.
Q 6)i) PHP Functions
Besides the built-in PHP functions, we can create our own functions.
A function is a block of statements that can be used repeatedly in a program.
A function will not execute immediately when a page loads.
A function will be executed by a call to the function.

Create a User Defined Function in PHP


A user-defined function declaration starts with the word function:
Syntax
function functionName() {
code to be executed;
}
Note: A function name can start with a letter or underscore (not a number).
Tip: Give the function a name that reflects what the function does!
Function names are NOT case-sensitive.
In the example below, we create a function named "writeMsg()". The opening curly brace ( { ) indicates the beginning of
the function code and the closing curly brace ( } ) indicates the end of the function. The function outputs "Hello world!". To
call the function, just write its name:
Example
<?php
function writeMsg() {
echo "Hello world!";
}

writeMsg(); // call the function


?>
ii) A Web server is a program that uses HTTP (Hypertext Transfer Protocol) to serve the files that form Web pages to
users, in response to their requests, which are forwarded by their computers' HTTP clients. Dedicated computers and
appliances may be referred to as Web servers as well.
The process is an example of the client/server model. All computers that host Web sites must have Web server programs.
Leading Web servers includeApache (the most widely-installed Web server), Microsoft's Internet Information Server (IIS)
and nginx (pronounced engine X) from NGNIX. Other Web servers include Novell's NetWare server, Google Web Server
(GWS) and IBM's family of Domino servers.
Web servers often come as part of a larger package of Internet- and intranet-related programs for serving email,
downloading requests for File Transfer Protocol (FTP) files, and building and publishing Web pages. Considerations in
choosing a Web server include how well it works with the operating system and other servers, its ability to handle server-
side programming, security characteristics, and the particular publishing, search engine and site building tools that come
with it.
Q 8) i) PHP - The if...else Statement
The if....else statement executes some code if a condition is true and another code if that condition is false.
Syntax
if (condition) {
code to be executed if condition is true;
} else {
code to be executed if condition is false;
}
The example below will output "Have a good day!" if the current time is less than 20, and "Have a good night!"
otherwise:
Example
<?php
$t = date("H");

if ($t < "20") {


echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
iii) Hypertext Markup Language (HTML) is the standard markup language for creating web pages and web applications.
With Cascading Style Sheets (CSS) and JavaScript, it forms a triad of cornerstone technologies for the World Wide
Web.[4]
Web browsers receive HTML documents from a web server or from local storage and render the documents into
multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for the
appearance of the document.
HTML elements are the building blocks of HTML pages. With HTML constructs,images and other objects such
as interactive forms may be embedded into the rendered page. HTML provides a means to create structured
documents by denoting structural semantics for text such as headings, paragraphs, lists,links, quotes and other items.
HTML elements are delineated by tags, written using angle brackets. Tags such as <img /> and <input /> directly
introduce content into the page. Other tags such as <p> surround and provide information about document text and may
include other tags as sub-elements. Browsers do not display the HTML tags, but use them to interpret the content of the
page.

You might also like