我是新的 codeigniter 开发人员。我尝试在视图之间发送控制器,但只发送索引函数。当我尝试不同的功能时,我得到了这个错误。
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: sample
Filename: views/merhaba_sayfasi.php
Line Number: 8
我的控制器文件 = merhaba.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Merhaba extends CI_Controller {
public function index()
{
$data["title"]="İlk codeigniter sayfam";
$data["giris_baslik"] = "Merhaba Dünya";
$this->load->view('merhaba_sayfasi',$data);
}
public function example(){
$data["sample"] = "Sample php";
$this->load->view("merhaba_sayfasi",$data);
}
}
?>
我的视图文件 = merhaba_sayfasi.php
<html>
<head>
<meta charset="utf-8">
<title><?php echo $title; ?></title>
</head>
<body>
<h3><?php echo $giris_baslik; ?></h3>
<?php echo $sample; ?>
</body>
</html>
我的探险家图片
http://www.medyasef.com/questions/codeigniter_function_error.png