[PHP]在CodeIgniter中如何利用CSS创建视图 [PHP]如何使用CodeIgniter简化页面 网站地址:http://callmewhy.sinaapp.com/index.php/test 后面加上/testcss是测试CSS表单的页面 : http://callmewhy.sinaapp.com/index.php/test /testcss 加上testhead是测试头
[PHP]在CodeIgniter中如何利用CSS创建视图
[PHP]如何使用CodeIgniter简化页面
网站地址:http://callmewhy.sinaapp.com/index.php/test
后面加上/testcss是测试CSS表单的页面:http://callmewhy.sinaapp.com/index.php/test/testcss
加上testhead是测试头文件的插入:http://callmewhy.sinaapp.com/index.php/test/testhead
下面是以上两个案例的脚本文件。
完整的项目下载
首先是控制器Controller,文件名Test.php(要在config.php中配置):
<?php class Test extends CI_Controller { function __construct() { //继承父类的构造方法,不写报错 parent::__construct(); } function index() { $this->load->view('welcome_view'); } function testHead(){ //测试head页面的引入 $data['mytitle'] ="A website monitoring tool"; $data['mytext'] ="Test!Test!"; $data['myrobots'] ='noindex,nofollow'; $data['mywebtitle']='Web monitoring tool'; $data['base'] = $this->config->item('base_url'); $this->load->view('test_head_view',$data); } function testCss(){ $data['mytitle'] ="A website monitoring tool"; $data['mytext'] ="Test!Test!"; $data['base'] = $this->config->item('base_url'); $data['css'] =$this->config->item('test_css'); $this->load->view('test_css_view',$data); } } ?>
第一个测试CSS引入的view视图,文件名test_css_view.php:
<title>WHY's Test Page</title> <base href="<?php%20echo">"> <link rel="stylesheet" type="text/css" href="<?php%20echo">"> <h1><?php echo$mytitle;?></h1> <p class="test"><?php echo$mytext;?></p>
相应的CSS文件,文件名test.css:
h1{ margin : 5px; padding-left : 10px; padding-right : 10px; background : #ffffff; color : blue; width : 100%; font-size : 36px; } .test{ margin : 5px; padding-left : 10px; padding-right : 10px; background : #ffffff; color : red; width : 100%; font-size : 36px; }
第二个测试head嵌入的view视图,文件名test_head_view.php:
<?php $this->load->view('header_view');?> <h1><?php echo $mytitle;?></h1> <p><?php echo $mytext;?></p>
第三个是head的文件,文件名head_view.php:
<title><?php echo $mywebtitle?></title> <base href="<?php%20echo">"/> <meta name="robots" content="<?php echo $myrobots?>"> <link rel="stylesheet" type="text/css" href="<?php%20echo">"/>

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

WebStorm Mac版
好用的JavaScript開發工具

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

記事本++7.3.1
好用且免費的程式碼編輯器