텍스트와 PHP 오류를 절단 (더 심포니 설치, 그래서 config.yml 여기에 관련이 없습니다)이 내 코드입니다 :는 나뭇 가지, 나는 작은 간단한 나뭇 가지 사이트가
htaccess로 파일 :
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
employees.html :
<html>
<head>
<style type="text/css">
table {
border-collapse: collapse;
}
tr.heading {
font-weight: bolder;
}
td {
border: 1px solid black;
padding: 0 0.5em;
}
</style>
</head>
<body>
<h2>Employees</h2>
<table>
<tr class="heading">
</tr>
{% for d in data %}
<tr>
<td>{{ d.name|escape }}</td>
<td>{{ d.role|escape }}</td>
<td>{{ d.salary|escape }}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
종업원 VARCHAR (255)되고, 역할 MySQL은 VARCHAR (255)이다.
내 코드 :
<?php
// include and register Twig auto-loader
include 'Twig/Autoloader.php';
Twig_Autoloader::register();
// attempt a connection
try {
$dbh = new PDO('mysql:dbname=employedb1;host=localhost', 'test', 'test');
} catch (PDOException $e) {
echo "Error: Could not connect. " . $e->getMessage();
}
// set error mode
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// attempt some queries
try {
// execute SELECT query
// store each row as an object
$sql = "SELECT name, role, salary FROM employees";
$sth = $dbh->query($sql);
while ($row = $sth->fetchObject()) {
$data[] = $row;
}
// close connection, clean up
unset($dbh);
// define template directory location
$loader = new Twig_Loader_Filesystem('templates');
// initialize Twig environment
$twig = new Twig_Environment($loader);
// load template
$template = $twig->loadTemplate('employees.html');
// set template variables
// render template
echo $template->render(array (
'data' => $data
));
} catch (Exception $e) {
die ('ERROR: ' . $e->getMessage());
}
?>
내가 index.php에에 다음 수정을했다 때까지이 일을
은 (댓글이 원래 코드에서 실제로, 나뭇 가지 확장 위에 추가) : 그것은 때까지 일 http://pastebin.com/QMaQXEip
텍스트 확장을 추가하고이 오류가 발생했습니다. 치명적 오류 : 34 행의 /Applications/MAMP/htdocs/employtesttwig/index.php (위의 Twig_Extensions_Extension_Text()를 참조하는 34 행)에 클래스 'Twig_Extensions_Extension_Text'클래스가 없습니다.
왜 이런 일이 발생하며 어떻게이 오류를 해결할 수 있습니까?
감사합니다.
글쎄, 그 수업을해야합니까? – Maerlyn