0

Not much to explain really, I just cant figure out the correct syntax to use a variable in an include URL

heres what I thought it would be:

$round_num=1;
include '../../fixtures/round{$round_num}fix.php';

It returns the usual:

Warning: include(../../fixtures/round{$round_num}fix.php) [function.include]: failed to open stream: No such file or directory

This must be a very simple one for allot of you out there lol but i just cant find my answer ANYWHERE!

4

2 に答える 2

4

Use double quotes (") to delimit your string. String interpolation doesn't occur in single quoted (') strings.

$round_num=1;
include "../../fixtures/round{$round_num}fix.php";
于 2012-11-25T06:50:33.690 に答える
0

次のような代替構文を使用することもできます。

include "../../fixtures/round" . $round_num . "fix.php";

わかりやすくするために、IDE で変数を強調表示したい場合があります。

于 2012-11-25T06:55:59.783 に答える