更新: この php エラーが発生しています: この行で非オブジェクトのプロパティを取得しようとしています: if ($card->name == $fileRef){
__construct(x='') { definition }
関数を使用して呼び出すPHPでオブジェクトを構築しています$var = new Object('string');
コンストラクターは、対応する「file.php」に関連する文字列、つまり「file」を受け取ります。このクラスで使用可能なすべての file.php のカタログが json ファイルにあり、ディレクトリ情報が含まれています。
そして、おそらく私の構文でエラーをキャッチしていますか? …あと 2 日で、スイングしたいですか?
public function __construct($ctitle = '')
{
$fileRef = $ctitle.'php';
//Get the json card directory
$this->cardDirLocation = 'thisismyserver.com/CardDir.json';
$this->cardDir = file_get_contents($this->cardDirLocation);
$this->cardArray = json_decode($this->cardDir, true);
//Find the card listing from CardDir.json based on form response input and construct a Card class instance or use the main page (default)
foreach ($this->cardArray['Cards'] as $key => $val) { //search through each card IS THIS MY ERR??
if ($card->name == $fileRef){ //if the name matches a name in the cardDir.json file
//Fill Values
}
if ($this->title == ''){ //or if there is no title
$this->title = 'Get Started at The Home Page'; //refer to default values -> the home page
$this->dir = 'cards/start/';
$this->name = 'start.php'; ...etc
エラー: $fileRef 変数を json ファイル配列内の何かと一致させることができないため、常に「else if」のデフォルトになります。json ファイルは次のようになります。
{"Cards":[{"title":"何か", "name":"file.php", "dir":"somefile/dir/here/" }, {"title":"何かと違う", "name":"xfiles.php", "dir":"somefile/dir/there/" ...など