Mac*_*Luc 1 php variables return function
我希望从我的PHP函数返回一个或另一个字符串变量.
我不想在函数中回显字符串我只想返回变量,然后在代码中输出它.
以下代码代表我的代码(简化):
<?php
$a = NULL;
$b = NULL;
myFunction($this);
function myFunction($this) {
if($this === a) {
return $a = "its a";
}else{
return $another = "its something else";
}
}
?>
<html>
MARKUP
<?php echo $a; ?>
<?php echo $b; ?>
Run Code Online (Sandbox Code Playgroud)
我觉得你误解了如何运作功能.
function myFunction($this, $a) {
if($this === $a) {
return "its a";
}else{
return "its something else";
}
}
$result = myFunction($this, $a);
Run Code Online (Sandbox Code Playgroud)
我想你想这样做
| 归档时间: |
|
| 查看次数: |
1778 次 |
| 最近记录: |