Health Advantages Of Lemon Juice In Summer

When The Hot Summer Days Are Around, We’ve Got One Thing In Our Minds When It Comes To Drinks: Fresh Lemon Juice. It Is A Very Popular Beverage. Taking Lemon Juice Regularly Helps Build Up Your Metabolism And Hence Assists Your Digestive Organs To Remove Toxics And Dirt From Your Stomach Faster.

Drinking Lemon Juice In The Morning Gives The Body A Chance To Absorb The Vitamins Effectively. Healthy Advantages Of Lemon Juice:

1. Purifying, Detoxifying The Body:

D-limonene, a substance that activates enzymes in the liver, helps promote the hepatic activity of the liver, thereby helping the liver to eliminate toxins in the body.
Moreover, lemon is very diuretic. Drinking lemon juice makes you urinate more, so the toxin also urinate out.
Therefore, fresh lemon juice is considered to be able to detoxify the body very well. Every morning, drink a glass of lemonade, so that all the residue in the body for a long night is discharged out.

2. Strengthen The Immune System:

Lemon juice is capable of boosting the body’s immune system because it contains a lot of vitamin C. This vitamin has both anti-inflammatory and anti-inflammatory properties, which helps to increase iron absorption – minerals that play a role in immune function.

3. PH Balance:

Lemon contains an excellent alkaline substance, which helps balance the pH of the body, especially for those who are prone to pH imbalances such as those with high protein diets, cheese and alcohol.
If the body loses its pH balance, it produces a variety of diseases, so drinking regular lemonade in the morning helps keep your body balanced throughout the day, helping you stay healthy.

4. Good For The Digestive System:

Citric acid helps improve the absorption of aluminum hydroxide – the active ingredient helps reduce the acid concentration in the stomach, thereby promoting the digestive system.More reduce symptoms indigestion, heartburn if the body You have this trouble.

5. Reduce Respiratory Disease:

Taking morning lemon juice helps to remove the bacteria that cause infections in the throat and chest so that you can help reduce the number of respiratory diseases. This method is very beneficial for people with dry cough, wind cough, patients with asthma and allergies.

6. Improves Skin Beauty:

Lemon contains a lot of vitamin C, so it is effective in anti-aging, skin beauty, wrinkles and acne reduction on the surface of the skin. Furthermore, vitamin C helps to eliminate toxins from the inside so it helps beautiful skin from the root rather than just the surface.

7. The Way To Drink Lemonade In The Morning:

You do not mix lemon juice in the usual way when drinking refreshments ie lemonade with sugar and ice. Use a glass of warm water and a little honey to make lemonade. Warm water and honey are also good for health, help kill bacteria and increase resistance. This great trio will be like a protective armor for your health.

log form data javascript

Example

 
// Create a test FormData object var formData = new FormData(); formData.append('key1', 'value1'); formData.append('key2', 'value2'); // Display the values for (var value of formData.values()) { console.log(value); }

The result is:

value1
value2

Send and Upload file and data using ajax jquery

<script>
var files;
$('input[type=file]').on('change', prepareUpload);
function prepareUpload(event){
files = event.target.files;
};
function sendChat(type){
var formData = new FormData();
var content=$("#content").val();
formData.append('meetup_id', meetup_id); formData.append('type', type); formData.append('content', content); $.each(files, function(key, value){ formData.append(key, value); alert(value); });
return false;
$.ajax({
url: 'api/url.php',
type: 'POST',
data:formData,
dataType: 'json',
"processData": false,
"contentType": false,
"mimeType": "multipart/form-data",
headers: {
"Authorization": AUTH_ADITYA,
"Accept": "application/json",
"cache-control": "no-cache",
},
beforeSend: function () {
alert(content);
alert(meetup_id);
},
complete: function (data) {
$("#content").val('');
},
success: function (data) {

},
error: function (xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
</script>

7 Popular Java Frameworks for 2019

List of 7 Popular Java Frameworks for 2019

Although the list begins with the most popular one but is not an indicator of the best fit for your project. So, let’s begin without further ado.

1. Spring Framework

Any Java developer would vouch for its capability to create complex, high-performance web applications.

With simple components and configurations, this modular framework enables you to develop enterprise-level Java applications with much ease. Its DI-dependency injection feature and compatibility with other frameworks such as Kotlin and Groovy make it Java developers’ favorite.

Spring Framework utilizes inversion of control (IoC) design principle and so for developers, it is easier to focus a module on the task and free the modules from the assumptions and make programs extensible.

It has a number of modules to achieve different functionality in an application such as Spring core (Base module), Spring AOP (for cross-context logic), Spring Transaction (For transaction support), Spring MVC (Web aspect), and more.Used For

  • Enterprise Java (JEE)
  • Web application development
  • Distributed application
  • Core features can be used for creating any Java applications
  • All layer implementations of a real-time application

Advantages

  • All-inclusive programming and configuration model
  • Support traditional database RDBMS as well as new NoSQL
  • Provide backward compatibility and testability of code
  • Loose coupling can be achieved using IoC
  • Supports Aspect Oriented Programming and enables cohesive development
  • JBDC abstraction layer for exceptional hierarchy

Limitations

  • Steep learning curve, most developers struggle with IoC and Dependency Injection
  • Configurations keep on changing so developers have to keep themselves updated with the latest change.
  • Although Dependency Injection is one of its strengths, it makes the project dependent on Spring framework

2. Grails

Grails is a dynamic framework, anchored by the Groovy JVM programming language. It works with Java technologies, including Java EE containers, Spring, SiteMesh, Quartz, and Hibernate.

This open source web development framework is widely popular among Java developers for Enterprise Java Beans or EJB support. Because of this, it does not need to configure the XML and so developers can quickly start the development process of creating a robust and scalable application.Used for Building

  • Content management systems
  • e-Commerce sites
  • RESTful web services

Advantages

  • Easy to use object mapping library
  • Simple GORM
  • A controller layer built on Spring Boot
  • Flexible profiles
  • Embedded Tomcat container for on the fly reloading
  • Advanced plugin system featuring hundreds of plugins
  • A responsive and supportive communit

Limitations

  • Runtime language and so error-prone
  • Not the best choice for multi-threaded app
  • Need to purchase IntelliJ Idea, do not support any other IDE
  • Must learn Groovy language
  • Complex integration process

3. Blade

This 2015 born framework is so simple and lightweight that any developer from project’s perspective can understand it in a single day.

Based on Java 8, Blade, a lightweight MVC Framework provides a RESTful-style routing interface, making the web API cleaner and much easier to understand and synchronizing data with the website.Used For

  • Full-stack web framework for creating web applications rapidly

Advantages

  • Simple, small (smaller than 500KB) and clear coding structure
  • Multiple components to choose from
  • Multiple configuration files support
  • CSRF (Cross-Site Request Forgery) and XSS (Cross-site scripting) defense support
  • Support plug-in extensions and webjar resources
  • Embedded jetty server and template engine support

Limitations

  • Complex dependency engine
  • Lack mobile-app richness
  • Heavy documentation

4. Google Web Toolkit

GWT is a completely free, open-source framework that enables the developers to write client-side Java code and deploy it as JavaScript. Many Google products have been written using GWT such as AdSense, AdWords, Google Wallet, and Blogger.

Using this framework, developers can easily write complex browser applications rapidly. GWT allows developers to develop and debug Ajax applications in the Java language.

During deployment, its cross-compilers translate the Java Applications to standalone JavaScript files. It comes with many features such as cross-browser portability, internationalization, bookmarking, and history and management.Used For

  • Building progressive web apps
  • Creating and maintaining complex JavaScript front-end applications

Advantages

  • Supports reusable approach for common web development tasks
  • Support for full-featured Java debugging
  • Developer-friendly RPC mechanism
  • HTML Canvas support provided
  • Google APIs can be used in GWT applications
  • Developers can design applications in a pure object-oriented manner

Limitations

  • Java to JavaScript compilation is slow
  • Proprietary methods for defining the structure
  • Need to write more code even for simple things
  • Best suitable only for Java developers

5. JavaServer Faces (JSF)

JavaServer Faces makes web application development much easier leveraging on existing, standard UI and web-tier concepts. Developed by Oracle, it has a set of APIs for representing and managing UI components and custom tag library for expressing a JSF interface.

JSF is based on MVC software design pattern and has an architecture that clearly defines a distinction between application logic and representation.Used For

  • Building native applications
  • Web applications
  • Enterprise applications

Advantages

  • Create custom tags to a particular client device
  • Connect the presentation layer to the application code easily
  • Build user interfaces of reusable components
  • Use XML instead of Java for view handling

Limitations

  • Incompatibility with standard Java technologies
  • Complex to perform simple tasks
  • Lack of flexibility
  • Minimum Ajax support
  • Steep learning curve

6. Play

Its popularity can be estimated by the fact that it is widely used by top companies such as Samsung, LinkedIn, Verizon, The Guardian, and more. Since it uses an asynchronous model that allows statelessness principle, play framework offers speed, performance, and scalability.

Built upon Akka Toolkit, Play framework abridge the creation of concurrent and distributed applications on the Java Virtual Machine. Its user interface is simple and intuitive and so developers can easily understand its basic features to begin the development project quickly.Used For

  • Web applications that demand consistent content creation
  • Building Java and Scala applications for desktop and mobile interfaces

Advantages

  • Hot reload for all Java code, configurations, and templates
  • Supports non-blocking I/O which is crucial for high-performance apps
  • Open source with a large community to contribute
  • Commercial support is also available
  • Compile and runtime error can be handled well

Limitations

  • Steep learning curve, extensive documentation
  • Acts volatile sometimes

7. Struts

Here’s another enterprise-level framework maintained by Apache Software Foundation. This full-featured Java Web Application Framework allows the developers to create easy-to-maintain enterprise-level Java application.

One of the most noted features of Struts is its plugins which are basically JAR packages. Means they are portable and can be added in the classpath of the app.

For object-relational mapping, you can use the Hibernate plugin and for dependency injection, you can rely on the Spring plugin.Used For

  • Enterprise application development

Advantages

  • Well-organized JSP, Java, and Action classes that reduce development time
  • Centralized configuration, as most of the Struts values are represented in property files or XML
  • Custom JSP tags available to output the properties of JavaBeans components
  • In-built capabilities for checking form values

Limitations

  • Single ActionServlet available, which causes scalability issues
  • Lack of backward flow
  • Less transparent
  • Non-XML compliance of JSP syntax

Conclusion

When it comes to Java frameworks, keep an open mind and research which one is best for you. There are so many frameworks that will suit your project but pick the one that requires less code to write your application and is easy to manage.

Here’s How Much Key Banks Charge For Non-Maintenance Of Minimum Balance

Here’s How Much Key Banks Charge For Non-Maintenance Of Minimum Balance

Leading banks of the country such as State Bank of India (SBI), ICICI Bank, HDFC Bank, PNB Bank, among others, charge customers for non-maintenance of average monthly balance (AMB) in their savings accounts. Average Monthly Balance (AMB) is the minimum average of deposits required by the customers in their savings bank accounts. Customers failing to meet the AMB requirements in a month have to bear these penalty charges. However, the amount of penalty varies across banks on the basis of branch location.

Here’s a comparison of penalty charges for non-maintenance of AMB in SBI, HDFC Bank, ICICI Bank and PNB Bank:

State Bank of India (SBI):

SBI customers who have accounts in metro and urban centres are required to maintain an average monthly balance of Rs. 3,000. Customers who maintain a balance equal to or less than 50 per cent of the required monthly balance are charged Rs10 per month plus the applicable GST (Goods and Services Tax) rate.

Metro and urban branch (required MAB Rs. 3,000)Charges
Shortfall <= 50%Rs. 10 + GST
Shortfall > 50-75%Rs. 12 + GST
Shortfall > 75%Rs. 15 + GST
Semi-urban branch (required MAB Rs. 2,000)
Shortfall <= 50%Rs. 7.50 + GST
Shortfall > 50-75%Rs. 10 + GST
Shortfall > 75%Rs.12 + GST
Rural (required MAB Rs. 1,000)
Shortfall <= 50%Rs. 5 + GST
Shortfall > 50-75%Rs. 7.50 + GST
Shortfall > 75%Rs. 10 + GST

HDFC Bank:

Customers with a regular savings account in HDFC Bank branches located in metro and urban areas are required to maintain an average monthly balance of Rs. 10,000. The AMB required in semi-urban and rural locations is Rs. 5,000 and Rs. 2,500 respectively. The lender charges Rs. 150 if the amount in savings account is less than Rs. 10,000 but more than Rs. 7, 500, for metro and urban locations.

Description of ChargesRegular Savings Account
Minimum Average Balance RequirementsMetro / Urban branches: AMB Rs.10,000/-,
Semi-Urban Branches: AMB Rs.5,000/- ,
Rural Branches: AQB Rs.2,500/- or Fixed Deposit of Rs. 10,000 for minimum 1 year 1 day period
Charges applicable on non-maintenanceBalance Non-Maintenance Charges*
AMB Slabs Metro & UrbanSemi Urban
(in Rs.)AMB Requirement –Rs. 10,000/-AMB Requirement –Rs. 5,000/-
>=7,500 to < 10,000Rs. 150/-NA
>=5,000 to < 7,500Rs. 300/-NA
>=2,500 to < 5,000Rs. 450/-Rs. 150/-
0 to < 2,500Rs. 600/-Rs. 300/-
* plus taxes as applicable
AMB – Average Monthly Balance
AQB Slabs (in Rs.)Balance Non-Maintenance Charges* (per quarter) – Rural Branches
>= 1000 < 2,500Rs. 270/-
0 – <1000Rs. 450/-
*plus taxes as applicable
AQB – Average Quarterly Balance

ICICI Bank:

Customers with a regular savings account in ICICI Bank branches located in metro and urban areas need to maintain an average monthly balance of Rs. 10,000.

Minimum monthly average balance (MAB)*Metro and Urban locations – Rs.10,000
Semi-urban locations – Rs.5,000
Rural locations – Rs.2,000
Gramin locations – Rs.1,000
Charges for non maintenance of minimum monthly average balance (NMMAB)Metro/Urban/Semi-Urban/Rural locations :
Rs. 100 + 5% of the shortfall in required MAB
Gramin locations : 5% of the shortfall in required MAB

PNB Bank:

Customers with a regular savings bank account in PNB located in metro, urban, semi-urban areas are required to maintain a minimum quarterly average balance of Rs. 2,000.

Minimum quarterly average balance (QAB) & charges for not maintaining QABArea Of BranchMinimum Quarterly. Average BalanceIncidental Charges
RuralRs.1000/-From Rs. 25 to 250 as per location, category and deficit in QAB as per brackets in Rs.100s
Semi- UrbanRs.2000/-
UrbanRs.2000/-
MetropolitanRs.2000/-

There are certain accounts where AMB rules are not applicable. These accounts are called as zero balance savings accounts.

HTACCESS BEST PERFORMANCE CODE


# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

# Turn on Expires and set default to 0
#ExpiresActive On
#ExpiresDefault A0
 
# Set up caching on media files for 5 weeks

#ExpiresDefault A3024000
#Header append Cache-Control "public"

 
# Set up caching on media files for 5 weeks

#ExpiresDefault A3024000
#Header append Cache-Control "public"

 
# Set up 1 day caching on commonly updated files

#ExpiresDefault A86400
#Header append Cache-Control "proxy-revalidate"

 
# Force no caching for dynamic files

#ExpiresActive Off
#Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
#Header set Pragma "no-cache"




# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

## EXPIRES CACHING ##

ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"


# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)

   php_flag display_errors Off
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 32M
   php_value post_max_size 8M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php70"
   php_value upload_max_filesize 2M
   php_flag zlib.output_compression On

# END cPanel-generated php ini directives, do not edit

10 Natural Antacids to Help With Heartburn & Better Digestion

Nothing can destroy a pleasant dining experience faster than an uncomfortable case of heartburn.  While most people reach for over-the-counter remedies or prescription medications to reduce the discomfort caused by heartburn, these often only offer temporary relief, and chronic use of these drugs can lead to other health problems in the long-term. As a safer approach, start by trying these natural antacids and methods instead, to help you experience better digestion and to start enjoying your favorite foods again.

The Misery of Heartburn

Heartburn is a common, unpleasant condition that millions of people suffer from.  It occurs when acid from the stomach backs up into the esophagus, resulting in a burning type of sensation in the throat and/or upper chest.

10 Natural Antacids for HeartBurn Better Digestion:

1. Chewing Gum for Better Digestion

You may think that chewing gum only helps to eliminate bad breathe after a meal, but research has shown that it may also provide other health benefits as well, including better digestion and heartburn prevention.  In one study, published in the Journal of Dental Research, individuals that suffered from gastroesophageal reflux disorder (GERD) had reduced symptoms when they chewed sugar-free gum for 30 minutes after a meal.   Chewing gum promotes the production of saliva which acts as a buffer against acid. Additionally, chewing gum results in more frequent swallowing, which helps to push the nasty acids out of your esophagus.

2. Baking Soda for Better Digestion

That little box of odorizing baking soda in your fridge can act as a handy natural antacid after meals.   Mix ½ -1 teaspoon of baking soda with a glass of water if you’re experiencing heartburn. While this remedy is effective, it is not advisable to use it too frequently, as it is high in sodium and could lead to negative side effects such as increased swelling and nausea.

3. Licorice for Better Digestion

This isn’t a free pass to indulge in the candy; rather, licorice root tea and extracts have been shown to aid with heartburn and improved digestion. It is believed to have natural stomach healing properties, and to help relieve heartburn symptoms.

4. Apples for Better Digestion

Eating a slice of apple can help to neutralize stomach acid, which in turn,  helps to alleviate heartburn symptoms.  Apple cider vinegar is also a natural antacid that is believed to calm heartburn symptoms.  Combine two tablespoons of apple cider vinegar with ½ cup of water, and drink immediately after eating for optimal digestive health benefits.

5. Aloe for Better Digestion

Aloe is a powerful and soothing remedy for skin, and also may help to sooth membranes on the inside of your body as well. Aloe juice has anti-inflammatory properties which may help to reduce inflammation of your esophagus and stomach, thereby reducing heartburn symptoms.  Drink half a cup of aloe juice before meals to experience better digestion.

6. Carrot juice

When combined with spinach, carrot juice can be a highly beneficial treatment for gastritis symptoms. Mixing equal parts carrot juice and spinach juice and drinking it in the morning regularly can help those suffering from chronic gastritis or heartburn.

7. Milk

A natural antacid, milk can help reduce the production of stomach acid. Milk is also a great source of calcium. Milk works by coating the stomach lining, helping to reduce gastritis symptoms and curb acid production

8. Bananas

Known for coating the stomach lining and neutralizing excessive stomach acid production. Eating ripe bananas can help relieve acute symptoms of heartburn as well.

9. Garlic

Raw garlic is packed with antibiotic properties that can help kill pathogenic microorganisms that commonly result in gastritis. While garlic is often blamed for causing heartburn, eating a clove or two can quickly get rid of it as well.

10. Ginger

One of the oldest remedies for heartburn, ginger is also a great remedy for treating nausea. Ginger can be eaten cooked, raw, or taken as a tea. To help indigestion, take one tbsp. of ginger and lemon juice with two tbsp. of honey in an 8oz glass of warm water for speedy results.

Other foods that aid better digestion

  • Yellow mustard
  • Probiotics
  • Apple cider vinegar
  • Almonds
  • Fennel seeds
  • Fruits and vegetables

Object Oriented Programming | CPP | JAVA | C# | PHP

We can imagine our universe made of different objects like sun, earth, moon etc. Similarly we can imagine our car made of different objects like wheel, steering, gear etc. Same way there is object oriented programming concepts which assume everything as an object and implement a software using different objects.

Object Oriented Concepts

Before we go in detail, lets define important terms related to Object Oriented Programming.

  • 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 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.

Defining PHP Classes

The general form for defining a new class in PHP is as follows −

<?php
   class phpClass {
      var $var1;
      var $var2 = "constant string";
      
      function myfunc ($arg1, $arg2) {
         [..]
      }
      [..]
   }
?>

Here is the description of each line −

  • The special form class, followed by the name of the class that you want to define.
  • A set of braces enclosing any number of variable declarations and function definitions.
  • Variable declarations start with the special form var, which is followed by a conventional $ variable name; they may also have an initial assignment to a constant value.
  • Function definitions look much like standalone PHP functions but are local to the class and will be used to set and access object data.

Example

Here is an example which defines a class of Books type −

<?php
   class Books {
      /* Member variables */
      var $price;
      var $title;
      
      /* Member functions */
      function setPrice($par){
         $this->price = $par;
      }
      
      function getPrice(){
         echo $this->price ."<br/>";
      }
      
      function setTitle($par){
         $this->title = $par;
      }
      
      function getTitle(){
         echo $this->title ." <br/>";
      }
   }
?>

The variable $this is a special variable and it refers to the same object ie. itself.

Creating Objects in PHP

Once you defined your class, then you can create as many objects as you like of that class type. Following is an example of how to create object using newoperator.

$physics = new Books;
$maths = new Books;
$chemistry = new Books;

Here we have created three objects and these objects are independent of each other and they will have their existence separately. Next we will see how to access member function and process member variables.

Calling Member Functions

After creating your objects, you will be able to call member functions related to that object. One member function will be able to process member variable of related object only.

Following example shows how to set title and prices for the three books by calling member functions.

$physics->setTitle( "Physics for High School" );
$chemistry->setTitle( "Advanced Chemistry" );
$maths->setTitle( "Algebra" );

$physics->setPrice( 10 );
$chemistry->setPrice( 15 );
$maths->setPrice( 7 );

Now you call another member functions to get the values set by in above example −

$physics->getTitle();
$chemistry->getTitle();
$maths->getTitle();
$physics->getPrice();
$chemistry->getPrice();
$maths->getPrice();

This will produce the following result −

Physics for High School
Advanced Chemistry
Algebra
10
15
7

Constructor Functions

Constructor Functions are special type of functions which are called automatically whenever an object is created. So we take full advantage of this behaviour, by initializing many things through constructor functions.

PHP provides a special function called __construct() to define a constructor. You can pass as many as arguments you like into the constructor function.

Following example will create one constructor for Books class and it will initialize price and title for the book at the time of object creation.

function __construct( $par1, $par2 ) {
   $this->title = $par1;
   $this->price = $par2;
}

Now we don’t need to call set function separately to set price and title. We can initialize these two member variables at the time of object creation only. Check following example below −

$physics = new Books( "Physics for High School", 10 );
$maths = new Books ( "Advanced Chemistry", 15 );
$chemistry = new Books ("Algebra", 7 );

/* Get those set values */
$physics->getTitle();
$chemistry->getTitle();
$maths->getTitle();

$physics->getPrice();
$chemistry->getPrice();
$maths->getPrice();

This will produce the following result −

  Physics for High School
  Advanced Chemistry
  Algebra
  10
  15
  7

Destructor

Like a constructor function you can define a destructor function using function __destruct(). You can release all the resources with-in a destructor.

Inheritance

PHP class definitions can optionally inherit from a parent class definition by using the extends clause. The syntax is as follows −

class Child extends Parent {
   <definition body>
}

The effect of inheritance is that the child class (or subclass or derived class) has the following characteristics −

  • Automatically has all the member variable declarations of the parent class.
  • Automatically has all the same member functions as the parent, which (by default) will work the same way as those functions do in the parent.

Following example inherit Books class and adds more functionality based on the requirement.

class Novel extends Books {
   var $publisher;
   
   function setPublisher($par){
      $this->publisher = $par;
   }
   
   function getPublisher(){
      echo $this->publisher. "<br />";
   }
}

Now apart from inherited functions, class Novel keeps two additional member functions.

Function Overriding

Function definitions in child classes override definitions with the same name in parent classes. In a child class, we can modify the definition of a function inherited from parent class.

In the following example getPrice and getTitle functions are overridden to return some values.

function getPrice() {
   echo $this->price . "<br/>";
   return $this->price;
}
   
function getTitle(){
   echo $this->title . "<br/>";
   return $this->title;
}

Public Members

Unless you specify otherwise, properties and methods of a class are public. That is to say, they may be accessed in three possible situations −

  • From outside the class in which it is declared
  • From within the class in which it is declared
  • From within another class that implements the class in which it is declared

Till now we have seen all members as public members. If you wish to limit the accessibility of the members of a class then you define class members as private or protected.

Private members

By designating a member private, you limit its accessibility to the class in which it is declared. The private member cannot be referred to from classes that inherit the class in which it is declared and cannot be accessed from outside the class.

A class member can be made private by using private keyword infront of the member.

class MyClass {
   private $car = "skoda";
   $driver = "SRK";
   
   function __construct($par) {
      // Statements here run every time
      // an instance of the class
      // is created.
   }
   
   function myPublicFunction() {
      return("I'm visible!");
   }
   
   private function myPrivateFunction() {
      return("I'm  not visible outside!");
   }
}

When MyClass class is inherited by another class using extends, myPublicFunction() will be visible, as will $driver. The extending class will not have any awareness of or access to myPrivateFunction and $car, because they are declared private.

Protected members

A protected property or method is accessible in the class in which it is declared, as well as in classes that extend that class. Protected members are not available outside of those two kinds of classes. A class member can be made protected by using protected keyword in front of the member.

Here is different version of MyClass −

class MyClass {
   protected $car = "skoda";
   $driver = "SRK";

   function __construct($par) {
      // Statements here run every time
      // an instance of the class
      // is created.
   }
   
   function myPublicFunction() {
      return("I'm visible!");
   }
   
   protected function myPrivateFunction() {
      return("I'm  visible in child class!");
   }
}

Interfaces

Interfaces are defined to provide a common function names to the implementers. Different implementors can implement those interfaces according to their requirements. You can say, interfaces are skeletons which are implemented by developers.

As of PHP5, it is possible to define an interface, like this −

interface Mail {
   public function sendMail();
}

Then, if another class implemented that interface, like this −

class Report implements Mail {
   // sendMail() Definition goes here
}

Constants

A constant is somewhat like a variable, in that it holds a value, but is really more like a function because a constant is immutable. Once you declare a constant, it does not change.

Declaring one constant is easy, as is done in this version of MyClass −

class MyClass {
   const requiredMargin = 1.7;
   
   function __construct($incomingValue) {
      // Statements here run every time
      // an instance of the class
      // is created.
   }
}

In this class, requiredMargin is a constant. It is declared with the keyword const, and under no circumstances can it be changed to anything other than 1.7. Note that the constant’s name does not have a leading $, as variable names do.

Abstract Classes

An abstract class is one that cannot be instantiated, only inherited. You declare an abstract class with the keyword abstract, like this −

When inheriting from an abstract class, all methods marked abstract in the parent’s class declaration must be defined by the child; additionally, these methods must be defined with the same visibility.

abstract class MyAbstractClass {
   abstract function myAbstractFunction() {
   }
}

Note that function definitions inside an abstract class must also be preceded by the keyword abstract. It is not legal to have abstract function definitions inside a non-abstract class.

Static Keyword

Declaring class members or methods as static makes them accessible without needing an instantiation of the class. A member declared as static can not be accessed with an instantiated class object (though a static method can).

Try out following example −

<?php
   class Foo {
      public static $my_static = 'foo';
      
      public function staticValue() {
         return self::$my_static;
      }
   }
	
   print Foo::$my_static . "\n";
   $foo = new Foo();
   
   print $foo->staticValue() . "\n";
?>	

Final Keyword

PHP 5 introduces the final keyword, which prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.

Following example results in Fatal error: Cannot override final method BaseClass::moreTesting()

<?php

   class BaseClass {
      public function test() {
         echo "BaseClass::test() called<br>";
      }
      
      final public function moreTesting() {
         echo "BaseClass::moreTesting() called<br>";
      }
   }
   
   class ChildClass extends BaseClass {
      public function moreTesting() {
         echo "ChildClass::moreTesting() called<br>";
      }
   }
?>

Calling parent constructors

Instead of writing an entirely new constructor for the subclass, let’s write it by calling the parent’s constructor explicitly and then doing whatever is necessary in addition for instantiation of the subclass. Here’s a simple example −

class Name {
   var $_firstName;
   var $_lastName;
   
   function Name($first_name, $last_name) {
      $this->_firstName = $first_name;
      $this->_lastName = $last_name;
   }
   
   function toString() {
      return($this->_lastName .", " .$this->_firstName);
   }
}
class NameSub1 extends Name {
   var $_middleInitial;
   
   function NameSub1($first_name, $middle_initial, $last_name) {
      Name::Name($first_name, $last_name);
      $this->_middleInitial = $middle_initial;
   }
   
   function toString() {
      return(Name::toString() . " " . $this->_middleInitial);
   }
}

In this example, we have a parent class (Name), which has a two-argument constructor, and a subclass (NameSub1), which has a three-argument constructor. The constructor of NameSub1 functions by calling its parent constructor explicitly using the :: syntax (passing two of its arguments along) and then setting an additional field. Similarly, NameSub1 defines its non constructor toString() function in terms of the parent function that it overrides.

NOTE − A constructor can be defined with the same name as the name of a class. It is defined in above example.

Govt extends deadline for GST sales return for March until Apr 23

The government has extended the last date for filing summary sales return, GSTR-3B, for March month by three days until April 23. 

“Due date for filing GSTR-3B for the tax period March 2019 has been extended to April 23, 2019,” a ticker on GST portal ‘gst.gov.in’ said. 

The last date for filing summary sales return and payment of taxes for March is April 20, 2019. 

AMRG & Associates Partner Rajat Mohan said, “Glitches in GSTN is leading to frequent extensions in the filing of tax returns. Tax filers also need to improve the habit of filing at the last date, leading to burden on the servers resulting in the collapse of the same.”

Half-baked scheme: how high refill cost is pushing Ujjwala beneficiaries back to chulhas

The government claims that the Pradhan Mantri Ujjwala Yojana is a success. But the ground reality is different. Most households don’t refill their LPG cylinders owing to high costs, and instead switch back to cow-dung cakes and firewood for cooking.