Home >Backend Development >PHP Tutorial >Introduction to CodeIgniter CLI Mode_PHP Tutorial

Introduction to CodeIgniter CLI Mode_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:24:40957browse

Let us take Hello World as an example and first create a simple controller. Using your text editor, create a file called tools.php and enter the following code:

Copy code The code is as follows:

class Tools extends CI_Controller {

public function message($to = 'World')
{
echo "Hello {$to}!".PHP_EOL;
}
}
?>

Then save this file to your application/controllers/ folder. Now normally you can access it via your website’s URL:

Copy code The code is as follows:

example.com/index.php/tools/message/to

In addition, we can also open a terminal in Mac/Linux, or enter "Run" and enter "cmd" under Windows, and enter the directory of our CodeIgniter project.

Copy code The code is as follows:

$ cd /path/to/project;
$ php index.php tools message

If you follow this step by step, you should see Hello World!.

Copy code The code is as follows:

$ php index.php tools message "John Smith"

At this point we pass it a parameter just like a URL parameter. "John Smith" is passed as a parameter, and the output becomes: Hello John Smith!.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825344.htmlTechArticleLet us take Hello World as an example and first create a simple controller. Using your text editor, create a file called tools.php and enter the following code: Copy code...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn