PHP sprintf()没有替换参数交换

The following code produces and undefined variable $s instead of "number two"

define("T1","one");
define("T2","two");

$test="number %2$s";

$test=sprintf($test, T1,T2);

echo $test;

Single quotes solve your problem. Double quotes cause PHP to interpolate your '$' as a variable.

<?php
define("T1","one");
define("T2","two");

$test='number %2$s';

$test=sprintf($test, T1,T2);

echo $test;

See it working