바보 같은 질문이 있습니다 ... 왜 변수를 전달하면 브라우저가 나를 반환합니까 정의되지 않은 변수 :? 난 그냥 내 첫 번째 방법 (광고, 동일한 절차)에 대한 복제. 그러나 광고가 작동하고 범주가 작동하지 않는 경우 이는 매우 어리 석습니다. 이유가 무엇입니까? 내가 내 작은 응용 프로그램을 보여변수를 전달하면 kohana 3.3이 작동하지 않습니다. 정의되지 않은 변수 :
내 컨트롤러 :
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Ads extends Controller_Template {
public $template = 'template';
// function indes Ads
public function action_index()
{
$ads = ORM::factory('ads')->find_all(); // load all object inside ads table
$view = new View('ads/index'); // load the view/ads/index.php
$view->set('ads', $ads); // set 'ads' object to view
$this->template->set('content', $view);
}
// view single ads
public function action_single()
{
$id = $this->request->param('id');
$record = ORM::factory('ads')
->where('id_ads', '=', $id)
->find();
$view = new View('ads/single');
$view->set('ads', $record);
$this->template->set('content', $view);
}
public function action_category()
{
$category = ORM::factory('category')->find_all();
$view = new View('ads/index');
$view->set('category', $category);
$this->template->set('content', $view);
}
} // End Ads
내 관심보기 (광고/index.php를)
<?php foreach ($ads as $obj) : ?>
<h3><?php echo HTML::anchor('/ads/single/'.$obj->id_ads, $obj->title_ads); ?></h3>
<p><?php echo $obj->description_ads; ?></p>
<p>Autore: <?php echo $obj->author_ads; ?> || creato il <?php echo $obj->date_ads; ?> || categoria: <?php echo HTML::anchor('#', $obj->category->category_name); ?></p>
<?php endforeach; ?>
<?php foreach ($category as $obj) : ?>
<?php echo $obj->id; ?>
<?php endforeach; ?>
브라우저에서 오류
ErrorException [ Notice ]: Undefined variable: category
이유 카테고리에 대해서만 ?? 광고가 아닌가요?
나는 게시물을 편집했습니다 – user0111001101