/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!

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..

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

also doesn't work..

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.