Sha*_*ain 3 css php codeigniter
嘿,我是Codeigniter的全新人物.在Controllers文件夹中,我创建了一个名为caller.php
的文件home1.php
,并在其中创建了一个文件\Views
.在root directory
我创建了一个名为图片文件夹中\Images
,并创建了一个css
命名的文件夹\css
.在图像文件夹中有6张图片.在css文件夹style.css
文件中存在.
在caller.php
我写
<?
class caller extends CI_Controller
{
function index()
{
$this->load->view('home1');
// what i have to write here lo load images....
}
}
Run Code Online (Sandbox Code Playgroud)
在home1.php
我写
<html>
<head>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/style.css">
// what i have to write here to load images
</head>
<body>
<div id="outer">
<div id="container">
<div id="images">
<img src="new.jpg" width="960" height="400"/>
<img id="image1" src="1.jpg" />
<img id="image2" src="2.jpg" />
<img id="image3" src="3.jpg" />
<img id="image4" src="4.jpg" />
<img id="image5" src="5.jpg" />
</div>
<div id="slider">
<a href="#image1">1</a>
<a href="#image2">2</a>
<a href="#image3">3</a>
<a href="#image4">4</a>
<a href="#image5">5</a>
</div>
...................................................
....................................................
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
现在为上面的代码我如何加载图像.请专家帮助我.如果需要额外的配置,请提及.
由于您已经在使用url帮助器,我建议使用base_url包装您的图像src属性,例如:
<img src="<?php echo base_url('images/1.jpg'); ?>" />
Run Code Online (Sandbox Code Playgroud)
正如在另一个答案中提到的那样,最好(强制性的?)将控制器中的类名称大写
class Caller extends CI_Controller { ...
Run Code Online (Sandbox Code Playgroud)