私が持っているのnこのようなPHPオブジェクト:PHPオブジェクト内にどのように条件を追加できますか?
$test
->key1(1)
->key2(1)
->key3(1);
は、その中に条件を追加することが可能ですか?このような
:あなたが欲しいものを
$test
if(true) ->key1(1)
->key2(1)
if(true) ->key3(1);
私が持っているのnこのようなPHPオブジェクト:PHPオブジェクト内にどのように条件を追加できますか?
$test
->key1(1)
->key2(1)
->key3(1);
は、その中に条件を追加することが可能ですか?このような
:あなたが欲しいものを
$test
if(true) ->key1(1)
->key2(1)
if(true) ->key3(1);
を例
if ($YOUR_KEY == "key1") {
//if key1 then do something
} elseif ($YOUR_KEY == "key2") {
//if key2 then do something
} else {
//if none condition work than do something else
}
ここ
$YOUR_KEY
あなたの変数があると"key1"
ため
if (condition) {
code to be executed if this condition is true;
} elseif (condition) {
code to be executed if this condition is true;
} else {
code to be executed if all conditions are false;
}
では、あなたの価値ある
($ test - > key1(1) - > key2(1) - > key3(1))何かを行うとどうしてですか? – FatalError
https://stackoverflow.com/questions/10046629/conditional-builder-method-chaining-fluent-interfaceおよびhttps://stackoverflow.com/questions/1189979/implementing-conditional-in-a-を参照してください。流暢なインターフェイス。 – Progman
この状態で何をチェックしますか? – shudder