php如何在cakephp中执行带有扩展名.ctp的文件?
问题描述:
我是cakephp的新手。我想知道如何PHP代码执行扩展名为.ctp的文件。 php如何在cakephp的.ctp文件扩展名中执行?如何使用cakephp技术在扩展名为.css的文件中执行php代码?php如何在cakephp中执行带有扩展名.ctp的文件?
答
视图内部的代码被执行,因为Cake使用include
来处理它。只要有一个PHP开始标签和语法是好的,是文件中的任何代码会被执行
include('any_file_you_want.with_any_extension');
:你可以这样做你自己。
答
look cakephp遵循MVC体系结构。
Hence the files structures are divided into 3 main modules:-
1.Model:- This the file in which you write your validations.
2.COntroller:- This the file where you write your programs logic.
3.View:- This is the file where you write your output/design in the form of HTML and also write Java script.
Now coming back to your question. The .ctp files are nothing but the View part of the cakephp. They are initiated/ called by the controllers. The controllers act as a heart of ur php.They are the one's to call your .ctp file and execute the file and also css files are called and handled by them only.
Go through the documentation throughly...
我理解文档可能会有点混乱,阅读它的4-5倍ü西港岛线得到KNW每一件事情生根粉蛋糕...
答
CakePHP是对MVC结构的PHP框架。 模型视图控制器的MVC支架。
模型:其中您的数据库表定义和所有的处理和验证,如果您有名为“USER”的表,那么要访问该表,您将在Model目录中创建UserModel.php。
控制器:对于每一个型号一个控制器是定义我们的业务logic.here我们的控制器名称将是UsersController.php
查看 ::查看文件扩展名有.ctp。它定义了如何在客户端浏览器上显示数据。
CakePHP的流程:客户端请求将转到第一个UsersController.php。控制器将从UserModel.php获取数据。处理检索到的数据后,Controller将此数据传递给View。 View(.ctp)文件包含HTML,CSS和客户端脚本数据,这些数据将返回到将显示的客户端计算机。