Introduction to CodeIgniterCLI mode

Source: Internet
Author: User
This article mainly introduces the CodeIgniterCLI mode. if you need it, refer to the CI framework.

Let's take Hello World as an example. First, create a simple controller. Use your text editor to create a file named tools. php and enter the following code:

The code is as follows:
Class Tools extends CI_Controller {

Public function message ($ to = 'world ')
{
Echo "Hello {$ }! ". PHP_EOL;
}
}
?>

Save the file to your application/controllers/folder. Under normal circumstances, you can access it through the URL of your website:

The code is as follows:
Example.com/index.php/tools/message/to

In addition, you can open the terminal in Mac/Linux, enter "run" in Windows, enter "cmd", and enter the directory of our CodeIgniter project.

The code is as follows:
$ Cd/path/to/project;
$ Php index. php tools message

If you run it step by step, you will see Hello World !.

The code is as follows:
$ Php index. php tools message "John Smith"

So far, we have passed a parameter to the URL parameter. "John Smith" is passed as a parameter, and the output is also: Hello John Smith !.

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.