Emanuil Rusev
Emanuil Rusev

Reputation: 35265

Including files from a directory

Does (a) have any benefits over (b)?

a) A function that returns the path to the file.

include util("array");

function util($name)
{
    return PATH."utils/$name.php";
}

b) A function that directly includes the file.

util("array");

function util($name)
{
    include PATH."utils/$name.php";
}

Upvotes: 0

Views: 85

Answers (2)

Sebastian
Sebastian

Reputation: 1429

I'd take the second option, because it would allow you to switch between include(), include_once(), require() and require_once() easily, in case you ever need that.

Upvotes: 2

Jake N
Jake N

Reputation: 10583

I'd recommend using classes and __autoload

Upvotes: 4

Related Questions