dan
dan

Reputation: 13

How to include part of a file?

I want to have one file from which PHP can source content text such as title, marquee and other small updates. I think I remember something like this in asp where you can point ASP to a line on a text file and it will pluck it out.

Upvotes: 1

Views: 1736

Answers (2)

mattbasta
mattbasta

Reputation: 13709

The file() function reads in a file and explodes it by line breaks into an array (which it returns). Perhaps you could put each "entry" on a separate line and then simply grab it by doing something like $filedata[$line].

Upvotes: 0

Zack Marrapese
Zack Marrapese

Reputation: 12091

In your PHP file, create a class:

class Foo {

    public static function getMarquee() { 
        return 'marquee';
    }

    ...

}

Then you can just call whichever method you want from any file:

require_once 'foo.php';

echo Foo::getMarquee();

Upvotes: 2

Related Questions