0

/php/FrontController.php

namespace FrontController;
class FrontController {
    public static function add($a, $b)
    {
        return $a+$b;
    }
}

/project/index.php

use FrontController;
echo FrontController::add(4,5);

error message:

    Warning: The use statement with non-compound name 'FrontController' has no effect in C:\wamp\www\project\index.php
    Fatal error: Class 'FrontController' not found in C:\wamp\www\project\index.php

I want to use namesapces instead of include and include_once but I keep having this kind of problems..
use ../php/FrontController.php; <-- syntax error occurs so I can't specify the file location..
I don't know what I have done wrong.. please help!

Edited by 9tontruck

2
Contributors
3
Replies
19
Views
3 Years
Discussion Span
Last Post by 9tontruck
0

If you use namespaces you want have to require or to have a autoloader class ? ust use logic .. you provided those data in a file … in somehow that file should be read..

Edited by jkon

0

$result = php\FrontController\FrontController::add(4,5);

also doesn't work..

0

I think this is a bad question. I will re post new one later
Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.