如何在包含文件中使用变量

时间:2017-11-01 13:06:51

标签: php

是否可以在include内包含变量的文件?

见这个例子:

$randfilescnt = rand(1,$filecount);

include('./quizes/Arrow/quiz'+ $randfilescnt +'.php');

我该怎么做?

2 个答案:

答案 0 :(得分:1)

像这样:

$randfilescnt = rand(1,$filecount);
include("./quizes/Arrow/quiz".$randfilescnt.".php");

答案 1 :(得分:0)

使用"。"用于php中的字符串连接

 $randfilescnt = rand(1,$filecount);

    include('./quizes/Arrow/quiz'.$randfilescnt.'.php');