PHP OOP: Traits

What is Traits?

  • Code is shortened by using Traits.
  • One code is used everywhere just by writing the trait function.

Example :

Output:

Multi traits use example:

Output:

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

PHP OOP: Late Static Binding

Late static Binding:

  • Late static binding helps to override name by using static in echo keyword.
  • It helps lot for writing minimum coding.
  • The message of the base class is printed using the self keyword and the message of the derived class is printed using the static keyword.

Example to printing the message of base class:

Output:

Example of printing the message of derived class:

Output:

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

PHP OOP : Static Members

What is Static Members ?

  • Static properties and methods can be used without creating an instance of the class.
  • The static keyword is used to declare properties and methods of a class as static.
  • Object not create.
  • Stack keyword use before access modifier.
  • Inside class use self::(use static method).
  • inherit use parent class name ::(properties).

Example :

Example Constructor :-

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

PHP OOP : Interfaces

What is Interfaces?

  • Interfaces help us to use multiple classes in a single class inherit.
  • Interfaces are declared with the interface keyword.
  • Derived class is called derived class.
  • object not be created in interface.
  • Property should not be defined in interface(class).
  • All interface methods must be public.
  • All methods in an interface are abstract.
  • To implement an interface, a class must use the implements keyword.

Example :-

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

PHP OOP : Overriding properties and Methods

Overriding Properties :

  • Same properties on both classes (base and derived class).

Overriding Methods :

  • Same name of method on both classes base or derived class.
Tagged : / / / / / / / / / / / / /

PHP OOP : Access Modifier (public, protected, private)

What is the access modifier?

Restrictions on properties and methods.

Types of access modifier

  1. public
  2. protected
  3. private

Public :

  • Access on base as well as derived class and outside of the class.
  • Everyone can see and access the data.
  • Not secure.
  • Override use.

Protected :

  • Base and Derived class.
  • No one gets access throughout the class.
  • Declare like protected property and method.
  • Not use override function.
  • Without permission no one can access any of these (properties & method).

Private :

  • Access itself.
  • Highly secured.
  • No one can access without permission.
  • Highly costly.
Tagged : / / / / / / / / / / / / / / /

PHP OOP : Inheritance

What is inheritance in php?

  • Inheritance is properties of PHP.
  • Accessing the feature of one class of another class.
  • Three types that is single, multiple and multilevel inheritance.
  • It is the four pillars of oops.
  • It allows a class to reuse the code from another class without duplicating it.
  • Two classes one is base/main another one is derived class.
  • Base class only use its own function but in Derived class it use both function base or derived class.

How to use inheritance in php?

class school {
}
class students extends school {
}
$sch =new school (); // only use class school 
$stu = new students (); // use both class school students (properties and methods)

Example of main/base class use :-

Example of inheritance:

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

JavaScript : Introduction

JavaScript :

  • JavaScript is used to create client-side dynamic pages.
  • JavaScript (js) is a light-weight object-oriented programming language.
  • JavaScript is not a compiled language, but it is a translated language.
  • The JavaScript Translator (embedded in the browser) is responsible for translating the JavaScript code for the web browser.
  •  JavaScript, users can build modern web applications to interact directly without reloading the page every time.
  • databases such as CouchDB and MongoDB uses JavaScript as their scripting and query language.

Features of JavaScript :

There are following features of js :-

  • Object-Centered Script Language
  • Light Weight and delicate
  • Interpreted language
  • Case Sensitive format/language
  • Ability to perform In Built Function
  • Statements Looping
  • Client edge Technology
  • Validation of User’s Input
  • Else and If Statement
  • It uses prototypes rather than using classes for inheritance.
  • It is supportable in several operating systems including, Windows, macOS, etc.
  • It provides good control to the users over the web browsers.

Application of JavaScript

JavaScript is used to create interactive websites. It is mainly used for:

  • Client-side validation
  • Manipulating HTML Pages
  • User Notifications
  • Dynamic drop-down menus
  • Displaying date and time
  • Displaying pop-up windows 
  • Alert dialog box
  • Confirm dialog box
  • Prompt dialog box
  • Back-end Data Loading
  • Presentations
  • Server Applications
  • Displaying clocks etc.

JavaScript Example :

Output :-

Welcome to JavaScript

Hello JavaScript by JavaScript

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

Bootstrap utilities : “Vertical align”

Easily change the vertical alignment of inline, inline-block, inline-table, and table cell elements.

Change the alignment of elements with the vertical-alignment utilities.

These are the classes:- .align-baseline, .align-top.align-middle.align-bottom.align-text-bottom, and .align-text-top as needed.

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

Bootstrap Utilities : Text

Text Utilities classes, contains various text properties, such as, text alignment, text wrapping, text overflow, text transformation, font weight, italics, monospace, resetting color of text, removing text decorations.

1. Text alignment :

  • .class text-justify
  • .class text-left
  • .class text-center
  • .class text-right
  • .class text-sm|md|lg|xl-left

2. Text wrapping and overflow :

  • .class text-wrap
  • .class text-nowrap
  • .class text-truncate

3. Word break :

  • .class text-break

4. Text transform :

  • .class text-lowercase
  • .class text-uppercase
  • .class text-capitalize

5. Font weight and italics :

  • .class font-weight-bold
  • .class font-weight-bolder
  • .class font-weight-normal
  • .class font-weight-light
  • .class font-weight-lighter
  • .class font-italic

6. Monospace :

  • .class text-monospace

7. Reset color :

  • .class text-muted

8. Text decoration

  • .class text-decoration-none
Tagged : / / / / / / / / / / / / /