CodeIgniterCLI mode introduction _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Introduction to CodeIgniterCLI mode. Let's take HelloWorld as an example to first create a simple controller. Use your text editor to create a file named tools. php and enter the following code: Copy the code so that we can use Hello World as an example to 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 !.

World is used as an example to create a simple controller. Use your text editor to create a file named tools. php and enter the following code :...

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.