Link to home
Create AccountLog in
PHP

PHP

--

Questions

--

Followers

Top Experts

Avatar of pmsguy
pmsguy

PHP Fatal error: Class 'abstract' not found
I have a class (myclass) that extends an abstract class (abby) and getting a fatal error saying the abstract class is not found when including the classes.

abby.php
<?
abstract class abby {
}
?>

myclass.php
<?
class myclass extends abby {
}
?>

main.php
<?
include 'abby.php';
include 'myclass.php';
$obj=new myclass();
?>

When I run main.php I am getting a fatal error:
PHP Fatal error:  Class 'abby' not found

Note: if I include the abstract class in my class file then I do NOT get the error.
myclass.php
<?
include 'abby.php';
class myclass extends abby {
}
?>

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of pmsguypmsguy

ASKER

I found my problem.

I had a class of a similar name being included in another directory.

include "../classes/include.php";
<?
include "myclass.php";
?>

and in my other subdir I am including a file of a similar name (myclass.php)
include "myclass.php";

ASKER CERTIFIED SOLUTION
Avatar of Beverley PortlockBeverley Portlock🇬🇧

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

SOLUTION
Avatar of Ray PaseurRay Paseur🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

PHP

PHP

--

Questions

--

Followers

Top Experts

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.