When i try and activate my custom plugin i get the error shown below but this makes no sense to me as it seems ok code wise.

Fatal error: Class 'Functionality\AlterTable\AlterTableComments' not found in C:\wamp64\www\wp-content\plugins\functionality\example.php on line 130

incase your wondering this is on line 130:

new AlterTableComments;
  • This simply means the class you are trying to initiate is not defined. Did you write the plugin yourself? – Jack Johansson Apr 18 '18 at 18:47
  • try to use class name with namespace prefix $a = '\namespacename\classname'; $obj = new $a; see php.net/manual/en/language.namespaces.dynamic.php – Bikash Waiba Apr 19 '18 at 6:14
  • $a = '\PethouseukFunctionality\AlterTable\AlterTableComments'; $obj = new $a; – Bikash Waiba Apr 19 '18 at 9:11
  • Add code snippet to your question if possible. – Bikash Waiba Apr 19 '18 at 9:57

What I conclude form your comments is pethouseuk-functionality.php

include 'AlterTableComments.php';

use PethouseukFunctionality\AlterTable;

$a = 'PethouseukFunctionality\AlterTable\test';
$a();  // function call

$b = 'PethouseukFunctionality\AlterTable\AlterTableComments';
$c = new $b; // new object

$c->yourfunction('test'); // Method call

Another file AlterTableComments.php


namespace PethouseukFunctionality\AlterTable;

interface AlterTableInterface{

    function yourfunction($param);


class AlterTableComments implements AlterTableInterface{
    function yourfunction($param){

function test(){
    echo 'this is test ';

Result: this is test string(4) "test"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.