Index. php, _ PHP Tutorial

Source: Internet
Author: User
When this file is used, the index. php file is imported ,. When this file is used, the entry file index. php is used. when this file is used, the entry file index. php? Php defines the path define (THINK_PATH,. ThinkPHP) stored in the ThinkPHP framework. when defining the name of the current project, the index. php file is used as the entry file,

Index. php

 


Conf/config. php

  'Configuration value' URL _ model' => 2, // 2 indicates URL rewrite mode); return array_merge ($ dbConf, $ Conf);?>


There is a configuration file config. inc. php at the same level as the entry file.

  'Configuration value' DB _ type' => 'mysql', 'DB _ host' => 'localhost ', // database NAME 'DB _ name' => 'think', // database USER 'DB _ user' => 'root ', // database password 'DB _ pwd' => '', // database PORT 'DB _ port' => '123 ', // table PREFIX 'DB _ prefix' => 't_',)?>


Controller IndexAction. class. php

  Display ("reg");} function add () {if (md5 ($ _ POST ['verify '])! = $ _ SESSION ['verify ']) {$ this-> error ("verification code error");} // instantiate the Custom Model M ('user ') instantiate basic model $ user = D ("User"); if ($ user-> create () {// execute the insert operation. after successful execution, returns the newly inserted Database ID if ($ user-> add () {$ this-> success ("registered successfully ");} else {$ this-> error ("registration failed ");}} else {// display the error message $ this-> error ($ user-> getError () ;}// generate the image verification code function verify () {/*** how to implement the verification code in thinkPHP *** ThinkPHP has provided us with the image processing class library ThinkPHP \ Extend \... ** How to import a class library? * The import class library uses "import (file path) for import, but note that \ in the file path should be replaced. "* 1) import the system class library import (starting from the library) import ('org. util. image ') note case sensitivity * 2) import the project class library import ("@. ORG. image ") we need to store * // import graphics processing class library import (" ORG. util. image "); // import ("@. ORG. image "); // Generate a graphic verification code/* length: the length of the verification code. the default value is 4-digit mode: the type of the verification string. the default value is a number, other supported types include 0 letters, 1 digit, 2 capital letters, 3 lowercase letters, 4 Chinese characters, and 5 characters (Removed confusing characters oOLl and numbers 01). type: the image type of the verification code, the default value is png width: the verification code width. by default, height is automatically calculated based on the verification code length. the default value is 22 verifyName: The SESSION record name of the verification code, the default value is verify * // The English verification code image: buildImageVerify (, 'GIF', 60, 22, 'verify '). // The Chinese verification code is implemented. // image :: GBVerify ();}}


Model UserModel. class. php

  15) {return false;} else {return true;} // return the visitor's IP address function getIp () {return $ _ SERVER ['remote _ ADDR '];} function shijian () {return date ("Y-m-d H: I: s ");}}


Template reg.html

  RegisterScript function show () {document. getElementById ("verify "). src = "/index. php/Article/verify/random "+ Math. random ();} script


If you still have any questions, please leave me a message. I will answer your questions in detail. thank you for your attention.

The directory structure is as follows:

TP

-------- ThinkPHP folder

-------- The File protal. php is called protal. php.

When you run protal. php, the welcome page of ThinkPHP appears, proving that the configuration is successful, and the directory results will change.

The directory is

TP

-------- ThinkPHP folder

-------- Protal. php entry file (the file above)

-------- Protal folder

The generated project directory structure is similar to the system directory, including:

Common

Project Public File Directory, generally placed in the project's public functions

Conf

Project configuration directory, where all configuration files of the project are stored

Lang

Project language pack Directory (optional, can be deleted if you do not need multiple languages)

Lib

The project class library directory, usually including the Action and Model subdirectories.

Tpl

Project Template directory, supporting template themes

Runtime

Project runtime Directory, including Cache (Template Cache), Temp (Data Cache), Data (Data directory), and Logs (log file) subdirectories. if there are groups, the first is the group Directory.

Mysql>SELECT FROM_UNIXTIME (875996580 );

-> '2017-10-04 22:23:00'

Mysql>SELECT UNIXTIME_TIMESTAMP ('2017-10-04 22:23:00 ');

->'875996580'

When this file is used, the entry file index. php? Php // define the PATH in which the ThinkPHP framework stores define ('think _ path', './ThinkPHP/'); // define the name of the current project...

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.