Tutorial for Polymorphism in OOPS

What is Polymorphism?

Polymorphism, as its name implies, comes in a variety of forms. OOP allows for the use of a variety of techniques I. Simply expressed, they have to do with how methods are used, and how different methods operate for different objects. Method Overriding and Method Overloading are two ways that polymorphic methods allow for different actions to be done.

The benefits of Polymorphism are:

  • Objects of different types can be passed through the same interface
  • Method overriding
  • Method overloading

Method Overriding:- Overriding is used in the polymorphism of runtime. By overriding a parent class’s method, a child class can implement a different method. In the case of our dogs, we may prefer a specific type of bark that is distinct from the generic type of dog (TrackingDog).

Example:-

TrackingDog’s overriding the bark() method

Method Overloading:- Overloading is used at the polymorphic build time. Although methods and functions may have the same name, the call method has its own set of arguments. Different results may be obtained depending on the number of parameters entered.

Example:- There are no parameters supplied to the updateAttendance() method. The count will be added one day. When the updateAttendance(4) argument is used, the x xupdateAttendance(x) parameter is used, and four days are added to the total.

Tagged : / / / / / / / / /

Tutorial for Abstraction in OOPS

What is Abstraction?

Basics of Computation Theory. What is "abstraction"? Abstraction unifies  multiple and different objects into one concept  describes the common  properties. - ppt download

Abstraction in OOP allows information/access about how codes are applied to be concealed, allowing just the required access. These details may be found in the object definitions. A famous example is the counting approach that works with list items. One thing to keep in mind is that, given the same OOP concept, all Python I data types and structures are objects. In this sense, a list is a class that has methods for completing tasks.

What is Abstraction in OOPS? - JournalDev

What is the Function of Abstraction?

Abstraction use simpler high-level instruments to get access to a complex object:

  • Using simple things to represent complexity
  • Hide complex details from user
JavaScript ES7 OOP. Abstraction. Class. #1 - YouTube

Abstraction also serves a significant security role. We only present selected data items and provide data access via classes and methods to protect the data from being exposed. In the case of an automobile, an open gas tank would make it impossible to continue driving.

There are some benefits of abstraction which is mention below:

  • Simple, high level user interfaces
  • Complex code is hidden
  • Security
  • Easier software maintenance
  • Code updates rarely change abstraction

Tagged : / / / / / / / / /

Tutorial for Inheritance in OOPS

what is Inheritance?

In OOP, the concept of inheritance allows a class to accept or have the properties of another class (inherited). A sub-class or derived class is a class that inherits the characteristics/methods of another class. Heritage reduces code redundancy, allowing the class to use other class methods without having to rewrite the code. This allows for dynamic programming using the main class’s methods (also called the parent class). A subclass has the same properties as a primary class, but it can also have additional methods that are either completely independent or not present in the main class.

What is the Function of Inheritance?

Children’s classes may be built to enhance the parent’s class functionality and add more characteristics once essential properties and behaviors have been defined in the parent’s class.

Example:-

This distinction is demonstrated by creating a parent class child class(HerdingDog) (Dog) and then adding a single herd() behaviour.

The following code shows how the child class (HerdingDog) inherits a parent class method (bark) (Dog), and the child class adds an extra method herd().

When the code uses the fluffy.bark() function, the method bark() travels up the child’s chain to find out where the bark method is declared.

Tagged : / / / / / / /

Tutorial for Object-oriented programming (OOP) Concept

Computer programming skills is in high demand in today’s technology culture for programming. Understanding object-oriented programming may be useful in the creation and management of software systems (OOP). This article covers the core concepts of OOP and illustrates them with simple examples.

What is Object-oriented programming (OOP)?

Object Oriented Programming: A curated set of resources

Object-oriented programming is the process of integrating variables (properties) and functions (methods) into a single object. These products are organized into classes that may be mixed and matched. OOP allows you to think about the objects in a program’s code as well as the various actions that go along with them.

What are the principles of Object-oriented programming (OOP)?

What are four basic principles of Object Oriented Programming? | by Munish  Chandel | Medium

Encapsulation, Abstraction, Inheritance, and Polymorphism are the four basic concepts of object-oriented programming. Although these concepts appear to be extremely complicated, understanding the broad framework of how they work is beneficial. The four basic hypotheses are as follows:

  1. Inheritance: child classes inherit data and behaviors from parent class
  2. Encapsulation: containing information in an object, exposing only selected information
  3. Abstraction: only exposing high level public methods for accessing an object
  4. Polymorphism: many methods can do the same task

Tagged : / / / / / / / / / /

Tutorial for Name Attribute in HTML for PHP

What is Name Attribute?

A set of attribute values plus an attribute identifier make up an attribute. The attribute identifier, often known as the attribute name, is a string that uniquely identifies a property. The content of an attribute is its value, and its type is not limited to that of a string. When you wish to define a specific attribute for retrieval, searches, or update, you use an attribute name. Operations that yield characteristics also return names (such as when you perform reads or searches in the directory).
You must be aware of specific directory server characteristics while using attribute names so that the result does not surprise you. These characteristics are discussed in the next section.

Uses of Name Attribute

  • The name attribute specifies a name for an HTML element.
  • This name attribute can be used to reference the element in a JavaScript.
  • For a <form> element, the name attribute is  used as a reference when the data is submitted.
  • For an <iframe> element, the name attribute can be used to target a form submission.
  • For a <map> element, the name attribute is associated with the <img>‘s usemap attribute and creates a relationship between the image and the map.
  • For a <meta> element, the name attribute specifies a name for the information/value of the content attribute.
  • For a <param> element, the name attribute is used together with the value attribute to specify parameters for the plugin specified with the <object> tag.

Name Attribute Used with:-

ElementsAttribute
<button>name
<fieldset>name
<form>name
<iframe>name
<input>name
<map>name
<meta>name
<object>name
<output>name
<param>name
<select>name
<textarea>name

Tagged : / / / / / / /

Tutorial for $_GET in Super Global Variables

What is $_GET?

$_GET is a global variable that is used to collect data from an HTML form after it has been submitted. The data is visible in the query string when the form uses method get to transmit data, thus the values are not concealed. The values in the URL are stored in the $_GET super global array variable.

Web Development Course: PHP lecture 1

Example:-

Output:-

Right now, we’re just seeing half of the rationale. We’ve generated a linked image of Nainital Lake in the preceding code, which will take us to the picture.php page and provide the parameters name=”Nainilake” and city=”Nainital” to it.

That is, if we click on the little image of Nainital Lake, we will be brought to the next page picture.php, where the parameters will be displayed. These arguments will be given to the next page using the get method, and they will be shown in the address bar, as get is the default way. When we wish to transmit data to an address, we use a question mark (?) to connect them to the address.

The address has the name=Nainilake parameter connected to it. If we wish to add more values, we may do so by appending an ampersand (&) after each key-value combination, similar to how city=Nainital is appended after the name parameter. Now, when you click on the image of Nainital Lake, we want the picture.php page to appear, along with the value of the parameter.

$_POST vs $_GET

PHP Variables and scopes
Tagged : / / / / / / / / /

Tutorial for $_POST in Super Global Variables

What is $_POST?

It’s a global variable that’s used to collect data from the HTML form after it’s been submitted. Because the data is not accessible in the query string when a form uses method post to transfer data, security standards are maintained in this manner.

Example:- A form with an input field and a submit button is shown in the example below. The form data is delivered to the file provided in the action element of the form> tag when a user submits the data by clicking “Submit.” For processing form data, we point to the file itself in this case. Replace it with the filename of your choosing if you want to process form data with another PHP file. The value of the input field may then be collected using the super global variable $_POST:

Output:-

Before filling Data.
Just filling some data
After clicking on Submit button

We have developed a form in the preceding code that accepts the user’s name and age and accesses the data using the $_POST super global variable when they submit the data. Each super global variable is an array, thus it may hold many values. As a result, we took the $_POST variable’s name and age and placed them in the $nm and $age variables. We have developed a form in the preceding code that accepts the user’s name and age and accesses the data using the $_POST super global variable when they submit the data. Each super global variable is an array, thus it may hold many values. As a result, we took the $_POST variable’s name and age and placed them in the $nm and $age variables.

Tagged : / / / / / / / / / /

Tutorial for $_REQUEST in Super Global Variables

What is $_REQUEST?

$_REQUEST is a super global variable that’s used to collect data when an HTML form is submitted. Because $_POST and $_GET accomplish the same purpose and are extensively used, $_REQUEST is rarely used.

Global Variables - Superglobals Several predefined variables in PHP are  "superglobals", which means that they are always accessible, regardless of  scope. - ppt download

Example:- A form with an input field and a submit button is shown in the example below. The form data is delivered to the file provided in the action element of the form> tag when a user submits the data by clicking “Submit.” For processing form data, we point to this file in our example. Replace it with the filename of your choosing if you want to process form data with another PHP file. The value of the input field may then be collected using the super global variable $_REQUEST:

Output:-

Empty box
Just fill some data
After Clicking on submit button it shows this result

We’ve constructed a form in the above code that accepts the user’s name as input and prints it when the submit button is pressed. Because we alter the data on the same page using PHP code, we transfer the data received in the form to the same page using the $_SERVER[‘PHP SELF’] element as stated in the action attribute. The $_REQUEST super global array variable is used to obtain the data.

Tagged : / / / / / / / / / /

Tutorial for $_SERVER in Super Global Variables

What is $_SERVER?

It’s a super global variable in PHP that keeps track of headers, paths, and script locations. Some of these components are used to obtain data from the $_SERVER super global variables.

Server IP (PHP $_SERVER variables) | Drupal.org

Example:-

Output:-

To retrieve some information, we used the $_SERVER components in the code above. Using the ‘PHP SELF’ element, we retrieve the current file name that is being worked on. Then, using the ‘SERVER NAME’ attribute, we retrieve the current server name. Then we use ‘HTTP HOST’ to retrieve the host name.

The following table lists the most important elements that can go inside $_SERVER:

Element/CodeDescription
$_SERVER[‘PHP_SELF’]Returns the filename of the currently executing script
$_SERVER[‘GATEWAY_INTERFACE’]Returns the version of the Common Gateway Interface (CGI) the server is using
$_SERVER[‘SERVER_ADDR’]Returns the IP address of the host server
$_SERVER[‘SERVER_NAME’]Returns the name of the host server (such as www.w3schools.com)
$_SERVER[‘SERVER_SOFTWARE’]Returns the server identification string (such as Apache/2.2.24)
$_SERVER[‘SERVER_PROTOCOL’]Returns the name and revision of the information protocol (such as HTTP/1.1)
$_SERVER[‘REQUEST_METHOD’]Returns the request method used to access the page (such as POST)
$_SERVER[‘REQUEST_TIME’]Returns the timestamp of the start of the request (such as 1377687496)
$_SERVER[‘QUERY_STRING’]Returns the query string if the page is accessed via a query string
$_SERVER[‘HTTP_ACCEPT’]Returns the Accept header from the current request
$_SERVER[‘HTTP_ACCEPT_CHARSET’]Returns the Accept_Charset header from the current request (such as utf-8,ISO-8859-1)
$_SERVER[‘HTTP_HOST’]Returns the Host header from the current request
$_SERVER[‘HTTP_REFERER’]Returns the complete URL of the current page (not reliable because not all user-agents support it)
$_SERVER[‘HTTPS’]Is the script queried through a secure HTTP protocol
$_SERVER[‘REMOTE_ADDR’]Returns the IP address from where the user is viewing the current page
$_SERVER[‘REMOTE_HOST’]Returns the Host name from where the user is viewing the current page
$_SERVER[‘REMOTE_PORT’]Returns the port being used on the user’s machine to communicate with the web server
$_SERVER[‘SCRIPT_FILENAME’]Returns the absolute pathname of the currently executing script
$_SERVER[‘SERVER_ADMIN’]Returns the value given to the SERVER_ADMIN directive in the web server configuration file (if your script runs on a virtual host, it will be the value defined for that virtual host) (such as someone@w3schools.com)
$_SERVER[‘SERVER_PORT’]Returns the port on the server machine being used by the web server for communication (such as 80)
$_SERVER[‘SERVER_SIGNATURE’]Returns the server version and virtual host name which are added to server-generated pages
$_SERVER[‘PATH_TRANSLATED’]Returns the file system based path to the current script
$_SERVER[‘SCRIPT_NAME’]Returns the path of the current script
$_SERVER[‘SCRIPT_URI’]Returns the URI of the current page
Tagged : / / / / / / / / / /

Tutorial for $GLOBALS in Super Global Variables

What is $GLOBALS?

$GLOBALS is a super global variable that may be accessed from anywhere in the PHP script. All global variables are stored in the array $GLOBALS[], where index is the global variable name that may be retrieved.

All global variables are stored in an array named $GLOBALS[index] in PHP. The variable’s name is stored in the index.

Global Variables - Superglobals Several predefined variables in PHP are  "superglobals", which means that they are always accessible, regardless of  scope. - ppt download

The example below shows how to use the super global variable $GLOBALS:

Example:-

Output:-

Two global variables, $x and $y, are declared in the above code and are given a value. Then, in the GLOBAL array, a function multiplication() is written to multiply the values of $x and $y and store the result in another variable $z.

Tagged : / / / / / / / / / /