control
1 <?php
2 if (! defined ( 'BASEPATH' ))
3 exit ( 'No direct script access allowed' );
4 class Hello extends CI_Controller {
5 public function sayHello() {
6 $name = "huiwanpeng";
7 @$count =file_get_contents('./num.txt');
8
9 $count = $count ? $count : 0;
10 $count = $count + 1;
11
12 $re = fopen('./num.txt', 'w');
13 fwrite($re, $count);
14 fclose($re);
15
16 $data = Array("name"=>$name,"count"=>$count);
17 $this->load->view ( "test_view",$data);
18 //echo "helloa";
19 }
20 }
view
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<?php echo $name ?>
<?php echo $count ?>
</body>
</html>