Returns the first value that is set. Based on Try.these() from Prototype.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
|
Required |
The attributes to test, as strings. Intended for testing properties of the $base object, but also works with variables if you place an @ symbol at the beginning of the command. |
|
|
|
Optional |
The base object to use, if any. |
|
|
|
Optional |
What to return if there are no matches. Defaults to |
Returns
Type |
Description |
|---|---|
|
Either a matching property of a given object, boolean |
Examples
Return the first non-falsey value.
// Test data
$obj = new StdClass;
$obj->a = null;
$obj->b = null;
$obj->c = 1;
$obj->d = null;
// Instantiate
$s3 = new AmazonS3();
// Success?
var_dump($s3->util->try_these(array('a', 'b', 'c', 'd'), $obj, true));
Result:
int(1)
Source
Method defined in utilities/utilities.class.php | Toggle source view (25 lines) | View on GitHub

