あなたのできることは、あなたの関数に直接渡すことです。あなたの関数は、変数名が渡された場合はその変数の値を、そうでなければすべての変数値を持つ配列でなければなりません。
としてあなたはそれを行うことができます。
<?php
// by default, it returns an array of all variables. If a variable name is passed, it returns just that value.
function getResponseInfo($var=null) {
// create your array as usual. let's assume it's $result
/*
$result = array('http_code'=>200,'http_status'=>'ok','content_length'=>1589);
*/
if(isset($var) && array_key_exists($var, $result)) {
return $result[ $var ];
} else {
return $result;
}
}
?>
はそれが役に立てば幸い:
<?php
// pass your variable to the function getResponseInfo, for which you want the value.
echo $var->getResponse()->getResponseInfo('http_code');
?>
あなたの機能。
"2つのメソッドを呼び出すことについてはわかりませんが、 $ var-> getResponse() - > getResponseInfo ..それらは理想的に離れていなければなりませんか? – Bono
私は同じ質問をし、それはhttp://stackoverflow.com/questions/2396782/parse-error-on-explode-foo-bar0-for-instanceの複製として閉じられました:( –