私は最近MVCを学びます。私はMVC構造体で私のウェブサイトをrebulidしようとすると、別の名前のsapace(多分私はOOPについてはあまり知らない)の中で関数を呼び出すための問題があります。ここに私のコードは次のとおりです。異なる名前空間で関数を呼び出すphp
namespace UserFrosting;
class GroupController extends \UserFrosting\BaseController {
public function testFunction($params){
//Simple test function that i had error: Call to undefined function UserFrosting\testFunction()
$params['Password'] = $pw;
$params['JSON'] = 'Yes';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
if (curl_errno($curl)) $obj = (object) array('Result' => 'Error', 'Error' => curl_error($curl));
else if (empty($response)) $obj = (object) array('Result' => 'Error', 'Error' => 'Connection failed');
else $obj = json_decode($response);
curl_close($curl);
return $obj;
}
public function loginNumber(){
$params = array("Command" => "SystemStats");
$api = testFunction($params);
echo "<h3>Server Status</h3>\r\n";
if ($api -> Result == "Error") die("Error: " . $api -> Error);
echo "Logins: " . $api -> Logins . "<br/>\r\n";
}
}
だから、基本的に私は、それはこのエラーを示し、loginNumber()
呼ば:未定義の機能UserFrosting \ testFunctionへ* コール()*
私はSoupClient
と同じ問題を抱えていたが、私はこのことを示していエラー:
public function templatePost(){
$client = SoapClient('https://www.test.com/pg/services/WebGate/wsdl', ['encoding' => 'UTF-8']);
$result = $client->PaymentRequest([
'MerchantID' => $MerchantID,
'Amount' => $Amount,
'Description' => $Description,
'Email' => $Email,
'Mobile' => $Mobile,
'CallbackURL' => $CallbackURL,
]);
if ($result->Status == 100) {
header('Location: https://www.test.com/pg/StartPay/'.$result->Authority);
} else {
echo'ERR: '.$result->Status;
}
}
私はsであった:* クラスのUserFrosting \のSoapClientが '*ここ は同じな名前空間での私のsoapClient
コードで見つかりません。エラー、私の問題は何ですか?どのようにこれらの関数を呼び出すことができますか?
ありがとう、このような問題をカバーするか、または単純な方法でMVCやOOPを説明する記事はありますか? – user4967821
OOPを説明する記事が必要な場合は、MVC(楽観的見積もり)で遊ぶには2年ほど早すぎます。 –