Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Flex's avatar
Level 4

failed to open stream: No such file or directory in PHP

working with plain php. and I have php files in My includes folder like this, newclass.int.php

<?php
class NewClass extends ParentClass {
    }
?>

parentclass.int.php

<?php

class ParentClass{
    public $name = "Hey There!";
}
?>

and index.php like this,

<?php
include 'includes/parentclass.int.php';
include 'includes/newclass.int.php';
$object = new NewClass;
?>


<html>
<head>
<title>oop php</title>
</head>
<body>
<?php
echo $object->name;
?>

</body>
</html>

but I got following error msg when running the server, include(includes/parentclass.int.php): failed to open stream: No such file or directory in C:\wamp64\www\ooptest\index.php on line 2

Warning: include(includes/newclass.int.php): failed to open stream: No such file or directory in C:\wamp64\www\ooptest\index.php on line 3

Fatal error: Uncaught Error: Class 'NewClass' not found in C:\wamp64\www\ooptest\index.php on line 4

Error: Class 'NewClass' not found in C:\wamp64\www\ooptest\index.php on line 4

how can I fix this problem?

0 likes
5 replies
tomopongrac's avatar

Try this

<?php
include __DIR__ . '/includes/parentclass.int.php';
include __DIR__ . '/includes/newclass.int.php';
tomopongrac's avatar

Strange, so to make clear your folder structure is like this

|index.php
|includes
    |parentclass.int.php
    |newclass.int.php
Flex's avatar
Level 4

No any solutions here...

Please or to participate in this conversation.