我有问题与php变量


I have trouble with php variable

我有一个关于php变量的小问题。我怎样才能让这成为可能?

<?php
echo $test;
$test = 'This is a test';
?>

我知道你可以用

轻松地修复它
<?php
$test = 'This is a test';
echo $test;
?>

但是我不能在我的页面上那样使用它。

有谁能告诉我如何在echo之后有一个变量吗??

兄弟…这是不可能的…如何在没有赋值的情况下输出变量的值…

<?php
echo getTest();
function getTest(){
    return 'This is a test';
}

你不能。变量必须在有值之前声明