book
include
   --lib
     --db.php
     --input.php(static methods)
   --config
      --config.php
      --file.php
index.php

this my folder structure.THe config.php has spl_autoload_register.

spl_autoload_register(function ($class) {
    if (file_exists("lib/{$class}.php")) {
        require_once "lib/{$class}.php";
    }else{
        require_once "include/lib/{$class}.php";
    }
});

i can access classes everywhere from project.but nont from book folder.I used namespace also.its not work for static method.

I am using the fig-standard auto loader. Pretty much all frameworks today are using the proposed loading standard.

to call static method of class with namespace, you can easily do it like this.. say we have a MyClasss with namespace

namespace App\Doer;

class MyClass
{

    public static function just_do_it()
    {
        return 'I am doing it';

    }

}

On another page we can include the class page

include_once('location_of_the_class.php');

use App\Doer as Dude;

## call the static method
 print_r(Dude\MyClass::just_do_it());
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.