我想做一個PHP函數,包裝變量,將檢查變量值,並更改它,如果它匹配另一個變量。 我敢肯定,我做錯了,但是......檢查一個PHP變量與一個泛型函數,將與任何變量
這是我到目前爲止有:
<?php
function Clear_Value(){
$val='NONE';
if(this== $val){ this=='';}
};
$one = 'One';
$two = 'Two';
$three = 'NONE';
$four = 'Four';
Clear_Value($one);
Clear_Value($two);
Clear_Value($three);
Clear_Value($four);
echo $one.'<br>';
echo $two.'<br>';
echo $three.'<br>';
echo $four.'<br>';
?>
我要爲輸出將是:
One
Two
Four
我希望這很清楚。我仍然在學習PHP的功能,所以任何指針都會很棒。
感謝
您只能使用'this'類中(這應該是'$ this')。 – nickb 2012-04-23 17:33:57