[PHP] simple test source code of codeigniter framework

Source: Internet
Author: User
Tags codeigniter

[PHP] How to Use CSS to create a view in codeigniter

[PHP] How to Use codeigniter to simplify pages

Address: http://callmewhy.sinaapp.com/index.php/test

Followed by/testcss is the page for testing CSS forms: http://callmewhy.sinaapp.com/index.php/test/testcss

Plus testhead is the insert of the test header file: http://callmewhy.sinaapp.com/index.php/test/testhead

The following is the script file for the above two cases.

Download complete project

The first is the controller. The file name is test. php (to be configured in config. php ):

<? Phpclass test extends ci_controller {function _ construct () {// inherits the constructor of the parent class. If no value is specified, the parent :__ construct ();} function index () is returned () {$ this-> load-> View ('Welcome _ view');} function testhead () {// test the introduction of the head page $ 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) ;}}?>

First, test the view introduced by CSS. The file name is test_css_view.php:


Corresponding cssfile, file name 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;}

The second test is the view embedded in the head. The file name is test_head_view.php:

The third is the head file. The file name is head_view.php:

<title><?php echo $mywebtitle?></title><base href="<?php echo"$base";?>"/><meta name="robots"content="<?php echo $myrobots?>"><link rel="stylesheet" type="text/css" href="<?php echo"$base/$css";?>"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.