UrbanPro

Learn PHP from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What is abstract class in php?

Asked by Last Modified  

1 Answer

Learn PHP

Follow 1
Answer

Please enter your answer

In PHP, an abstract class is a class that cannot be instantiated on its own and is meant to be subclassed by other classes. Abstract classes can have abstract methods, which are declared but not implemented in the abstract class. Subclasses that extend an abstract class must provide concrete implementations...
read more

In PHP, an abstract class is a class that cannot be instantiated on its own and is meant to be subclassed by other classes. Abstract classes can have abstract methods, which are declared but not implemented in the abstract class. Subclasses that extend an abstract class must provide concrete implementations for all abstract methods.

Here are the key features of abstract classes in PHP:

  1. Cannot be Instantiated:

    • An abstract class cannot be instantiated directly. It serves as a blueprint for other classes.
  2. May Contain Abstract Methods:

    • Abstract classes can declare abstract methods, which are methods without an implementation in the abstract class itself.
  3. May Contain Concrete Methods:

    • Abstract classes can also have regular (concrete) methods with implementations.
  4. Designed for Inheritance:

    • The primary purpose of abstract classes is to be extended by other classes. Subclasses inherit the structure (methods and properties) of the abstract class.
  5. Abstract Methods Must be Implemented:

    • Any class that extends an abstract class must provide concrete implementations for all abstract methods declared in the abstract class.

Here's an example of an abstract class in PHP:

php
abstract class Shape { abstract public function calculateArea(); // Abstract method without implementation public function displayArea() { echo "Area: " . $this->calculateArea() . PHP_EOL; } } class Circle extends Shape { private $radius; public function __construct($radius) { $this->radius = $radius; } public function calculateArea() { return pi() * pow($this->radius, 2); } } // Usage $circle = new Circle(5); $circle->displayArea();

In this example, Shape is an abstract class with an abstract method calculateArea(). The Circle class extends the Shape class and provides a concrete implementation for the calculateArea() method. The displayArea() method in the Shape class uses the abstract calculateArea() method to display the area of the shape.

 
 
 
read less
Comments

Related Questions

How can we complete PHP language in 30 days?
First at all as a php trainer i would ask if you know html,csss,javascript nicely or not. As per me you should be at mediator level in those things to start php. Ok hopping you know that. Then go for some...
Veerendra
0 0
6
What is the fee for php classess?
Php class fess:- Rs. 9k html css js core and adv php MySQL PDO and ajax
Manjunath
Can I build iPhone apps using Python?
Yes, you can use PyMob app where apps can be written purely in Python, and the compiler tool flow converts them in native source codes for various platforms. But there are some cons on using PyMob, the...
Sunil
0 0
5
PHP (LAMP) for entrepreneurs, is there any full time, fast track classes on PHP(LAMP) for entrepreneurs, who want are want to do some tech part in their startups
Yes, You have option. You can Join. Xpert Infotech, New Delhi. Before going through Silverlight live project training candidate should have knowledge of given concepts listed below: Knowledge of HTML...
Saee
0 0
6
How can I learn PHP?
first understand what is web server. then what is server side programming language. then start understanding how submitting form can reach to a php program. how get and post work. then
Diwaker

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

What is Type Juggle in PHP ?
Type Juggling means dealing with a variable type. PHP does not require explicit type definition in variable declaration. A variable's type is determined by the context in which the variable is used. Example,...

Hiding .php extension Using HTACESS File
If you wish to hide.php extension from your website, then create a .htaccess file in your project root and paste the following code : RewriteEngine On RewriteCond %{THE_REQUEST} ^{3,}\s/(.+)\.php*...

A New Way To Learn Web Development.
Hello, My name is Ajay. I work at a small IT company and yes on weekends provides some training and guidance and consultancy to students. Before past 7-8 months, I was just a random student just like so...

PHP Intro.
What is PHP? PHP is an acronym for "PHP Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP costs nothing, it is free to download and...

SQL Union Vs Union ALL
SQL UNION vs UNION ALL Operator Usage UNION: UNION combines the result set of two or more queries into a single result set. UNION removes duplicate records (where all columns in the results are the same). UNION...

Recommended Articles

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

Read full article >

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Looking for PHP Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for PHP Classes?

The best tutors for PHP Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn PHP with the Best Tutors

The best Tutors for PHP Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more