我有一个名为getSources()的函数; 在这个函数中,我想轻松地为常量指定数字。 我认为这样可行: p>
const A = 1;
ncst B = 2;
ncst C = 3;
nstst D = 4;
code> < / pre>
我可以这样做: p>
$ someValue = A;
code> pre>
但它不起作用。 我错过了什么? 我不希望在这个函数的范围之外使用这些变量。 p>
div>
I have a function called getSources(); In this function I want to easily assign numbers to constants. I figured this would work:
const A = 1;
const B = 2;
const C = 3;
const D = 4;
And I could just do this:
$someValue = A;
But it doesn't work. What am I missing? I don't want these variables to be used outside of the scope of this function.
我有一个名为getSources()的函数; 在这个函数中,我想轻松地为常量指定数字。 我认为这样可行: p>
const A = 1;
ncst B = 2;
ncst C = 3;
nstst D = 4;
code> < / pre>
我可以这样做: p>
$ someValue = A;
code> pre>
但它不起作用。 我错过了什么? 我不希望在这个函数的范围之外使用这些变量。 p>
div>