开发者

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 tex开发者_运维技巧t file and it will pluck it out.


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();


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜