前提・実現したいこと
タイトルどおり。
他ファイルのclassを読み込んできて、そのクラス内の関数を使用したい
発生している問題・エラーメッセージ
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "file:C:\xampp\htdocs\smarty-test.jp\templates\index.tpl" on line 11 "{$ci->displayIndex();}" - Unexpected ";", expected one of: "}" <-- thrown in C:\xampp\htdocs\smarty-test.jp\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 11
該当のソースコード
index.php
php
1require_once(realpath(__DIR__) . "/smarty/Autoloader.php"); 2require_once('lib/index-create.php'); 3Smarty_Autoloader::register(); 4 5$ci = new CreateIndex(); 6 7$smarty = new Smarty(); 8 9$smarty->assign('ci',$ci); 10$smarty->display('index.tpl');
index-create.php
php
1<?php 2 3/** 4*データ作成 5*/ 6class CreateIndex{ 7 function displyIndex(){ 8 9 inclue("DataBase.php"); 10 11 $ClsDb = new DataBase(); 12 13 $pdo = $ClsDb->getPdo(); 14 15 $SQL = "Select * From `データベース名`.`テーブル名`;"; 16 17 echo $SQL; 18 19 } 20}
index.tpl
tpl
1<!DOCTYPE html> 2<html> 3<head> 4 <meta charset="utf-8"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 6 <title></title> 7 <link rel="stylesheet" href="style/index.css"> 8</head> 9<body> 10 <div class="outer"> 11 {$ci->displayIndex();} 12 </div> 13</body> 14</html>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。