开发者

PHP Included files writing their own content from Importer values

I have a index.php file that will include several external files:

"content/templates/id1/template.php" "content/templates/id2/template.php" "content/templates/id3/template.php" etc.

All these files are loaded dynamically into index.php (it reads all folders inside "templates" directory and then includes every "template.php" file).

I want to make "template.php" to have the same code in all the "id1,id2,id3" folders, BUT to load values from index.php depending in开发者_运维技巧 which folder it stays..

How can I do that? Thank You!


You can have each template find out its directory like so:

/id1/template.php

 $path = dirname(__FILE__);
 $id  = pathinfo($path,  PATHINFO_BASENAME);

 echo "Hi, I'm the template in $id!";  // Will output "id1"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜