thinkphp Basic Knowledge points

Source: Internet
Author: User

Download Get: www.thinkphp.cnConfiguration1. Create a Web site root directory 2. Place the thinkphp frame directory 3. Access to the single entry file under the browserCatalog IntroductionApplication├─common Apply public module │├─common apply public Function directory │└─conf apply public profile directory ├─home default generated Home module │├─conf Module profile Directory │├─common module function public directory │ ─controller Module Controller Directory │├─model module model Catalog │└─view Module View file directory ├─runtime runtime directory │├─cache template cache directory │├─data data directory │├─logs log directory │└─temp cache directoryUse      CCreate a controller 1. Create the file file name format in the Controllers directory under the module directory USERCONTROLLER.CLASS.PHP2. Contents in the controller file <?phpnamespace Home\controller;use Think\controller;class Usercontroller extends Commoncontroller {} Controller method access index.php?m=home&c=user&a= DELETEINDEX.PHP/HOME/USER/DELETEMAC Three letters cannot be used to pass parameters M1. Database Configuration//Database configuration information ' db_type ' = ' mysql ',//database type ' db_host ' = ' 127.0.0.1 ',//server address ' db_name ' = ' lamp ',//database name ' Db_u SER ' = ' root ',//user name ' db_pwd ' + ',//password ' db_port ' + 3306,//Port ' Db_prefix ' + ',//database table prefix ' Db_charset ' =&G T    ' UTF8 ',//Character Set 2. Create object: $user = M (' user '); 3. Increase in database operation: $user->add ($data);     $user->data ($data)->add (), $user->create (); $user->add ();    Delete: $user->delete ($id); User->where ("id=100")->delete ();Modified: $user->save ($data);   $user->where ("id=100")->save ($data); $user->create (); $user->save ();find: Get a single $user->find ($id); $user->where ()->find ()Get multiple: Coherent operation $user->field ()->where ()->limit ()->order ()->select () Send SQL directly: $user->query (' SELECT * From user ') VVariable assignment: $this->assign (' title ', ' thinkphp '); template parsing: $this->display (); template file to find by default: View |---Controller with the same name directory |---|---method name. html$th    Is->display (' Add ');    Default Find template File View |---Controller directory with the same name |---|---add.html$this->display (' user/add '); Default template file to findView |---User |---|---add.htmlTemplate engine: Variable output: {$title} Modify delimiter: ' tmpl_l_delim ' = ' <{',     ' tmpl_r_delim ' + '}> ' super global variables         {$Think. Server.script_name}//Output $_server[' script_name '] variables         {$ THINK.SESSION.USER_ID}//Output $_session[' user_id '] variable         {$Think. Get.name}//Output $_get[' name] variable         {$Think. Cookie.name}//Output $_cookie[' name '] variable         {$Think. Post.name}// Output $_post[' name '] variables   functions using: {$name |md5} where custom functions are stored    :home/common/function.php    :common/ common/function.php        {$name |substr=1,4}    {:substr ($name, 1,4)} default value: {$info | Default= "This guy is lazy and leaves nothing"} ternary operator: {$status? ' Normal ': ' Error '} template replacement         __ROOT__: will replace the address of the current website (excluding domain name)         __PUBLIC__ : The common directory that will be replaced with the current site is usually/public/        __APP__: will replace the URL address of the current app (excluding domain name)         __module __: Will replace the current module's URL address (without domain name)       &NBSP __CONTROLLER__ (__ or __url__ compatible): will replace the current controller's URL address (without domain name)         __ACTION__: will replace the current action URL address (without domain name)         __SELF__: will replace the current page url  built-in tags ignore parsing:<literal></literal> include files: <include file= "Public/header"/> Template inheritance: <extend name= "base"/> Template Comment: {/* Comment content */} or {//comment content}foreach   &NBSP;:&LT;FOREAC H name= "list" item= "Vo" >    {$key}| {$vo. id}:{$vo. Name}    </foreach> support for multilayer traversal (up to 3 layers) if    <if condition= "($name eq 1) OR ($name GT "> value1    <elseif condition=" $name eq 2 "/>value2    <else/> value3  &nbs P </if>  do not allow > < compare tags in a condition string:    <eq name= "name" value= "value" > equals       & nbsp             <else/> not equal                   & nbsp </eq>php:    <?php echo ' hello,world! '; ?>        <php>echo ' hello,world! '; </php> debug: Turn on Debug mode    :define (' App_debug ', true), turn on TRACE debug: ' Show_page_trace ' =>true, variable debug    :    dump function Gets the last SQL execution statement:     $user->getlastsql ();     $user->_sql (); In particular, view the compilation cache for database operations when you are working on a template, if the template does not display the same results as expected, you can try to view the compilation cache and adjust the template according to the parsing results of the templates. Debugging a problem when the source code is a dividing line if the source code content does not have errors to prove that the server is not a problem if the source code is abnormal this time proves that the server is out of the question. Site setup steps              thinkphp configuration              place static templates under the Site Directory (public)            & nbsp: copy static HTML code into your current template             Adjust CSS and js file Paths (IMG)              determine which files are missing from the current page by viewing Firebug

Thinkphp basic Knowledge points

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.