ecmall is a framework system based on mvc pattern, which is somewhat similar to thinkphp. Let’s start with the ecmall entrance, ecmall entrance files upload/index.php, admin.php:
index.php starts the ecmall frontend, and after startup, it enters the ecmall framework core file ecmall.php. ecmall.php is equivalent to a dispatch center, receiving different control commands (app) and command-related operations (funciton), and then It performs allocation processing. Then the dispatch center transmits these commands (app) and methods (function) to the specific controller corresponding to the front-end control center. After receiving the command, the "controller" starts to implement execution control, and then passes the processed results to the view template file (template naming rule: appname.fucname.html).
When the controller receives the command and executes it, it can call the model acquisition method &m() of the dispatch center to instantiate a model and perform curd operations on the data.
index.php:
include(ROOT_PATH . '/eccore/ecmall.php'); /* 启动ECMall */ ECMall::startup(array( 'default_app' => 'default', 'default_act' => 'index', 'app_root' => ROOT_PATH . '/app', //加载系统所需要的基础类 'external_libs' => array( ROOT_PATH . '/includes/global.lib.php', ROOT_PATH . '/includes/libraries/time.lib.php', ROOT_PATH . '/includes/ecapp.base.php', ROOT_PATH . '/includes/plugin.base.php', ROOT_PATH . '/app/frontend.base.php', ), ));
ecmall.php:
class ECMall { /* 启动 */ function startup($config = array()) { /* 加载初始化文件 */ require(ROOT_PATH . '/eccore/controller/app.base.php'); //基础控制器类 require(ROOT_PATH . '/eccore/model/model.base.php'); //模型基础类 if (!emptyempty($config['external_libs'])) { foreach ($config['external_libs'] as $lib) { require($lib); } } /* 数据过滤 */ if (!get_magic_quotes_gpc()) { $_GET = addslashes_deep($_GET); $_POST = addslashes_deep($_POST); $_COOKIE= addslashes_deep($_COOKIE); } /* 请求转发 */ $default_app = $config['default_app'] ? $config['default_app'] : 'default'; $default_act = $config['default_act'] ? $config['default_act'] : 'index'; $app = isset($_REQUEST['app']) ? trim($_REQUEST['app']) : $default_app; $act = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : $default_act; $app_file = $config['app_root'] . "/{$app}.app.php"; if (!is_file($app_file)) { exit('Missing controller'); } require($app_file); define('APP', $app); define('ACT', $act); $app_class_name = ucfirst($app) . 'App'; /* 实例化控制器 */ $app = new $app_class_name(); c($app); $app->do_action($act); //转发至对应的Action $app->destruct(); } } //根据app后面所跟的参数,来判断加载对应的控制器类文件,类文件在app文件夹下,对应名称与参数相同,act后面的参数是对应控制器中的操作方法处理请求 //而对应的动作中,会有一个判断: if (!IS_POST){请求前的页面内容的显示}else{请求后的表单处理及处理完成后的页面跳转}。其中包括使用json处理数据 //这里需要提出的是:在控制器中: $this->assign('order', $order_info); //向模板页传递所需要参数的值 $this->display('buyer_order.confirm.html');//跳转到哪个页面 $this->json_result($new_data, 'confirm_order_successed');//使用json的方式传递参数,然后在页面上使用javascript处理请求的跳转
Due to this mechanism, APPs, modules, plug-ins, etc. can be added to ECMALL by yourself. How to add your own APP in ECMALL? For example, the access address is http://xxx.com/index.php?app=hello
- Create a new application file named hello.app.php in the app directory of ecmall
- Create the corresponding language file hello.lang.php in the sc-utf8 directory of languages, and return an array (if not created, an error will occur)
- The class in hello.app.php is HelloApp and inherits FrontendApp
- This is a front-end program. Create a hello.index.html template file in the themes/mall/default folder of ecmall
- Override the default index method and use template output:
- Write other methods such as access address http://xxx.com/index.php?app=hello&act=test
$h = "Hello"; $this->assign("h",$h); $this->display('hello.index.html');
This URL accesses the test method in the app class named hello. In fact, http://xxx.com/index.php?app=hello accesses the index method by default.
//1、在upload/app/下建立一个test.app.php <?php class TestApp extends MallbaseApp { public function index() { $str="hello world"; $uc_first= ucfirst($str).'<br>'; $uc_words=ucwords($str).'<br>'; $Model=&m('goods'); $res=$Model->get(27); print_r($res); $this->assign('ss',$uc_first); $this->assign('sss',$uc_words); $this->display('test.index.html'); } } ?> //2、在upload/languages/sc-utf-8/下建立一个test.lang.php <?php return array(); ?> // 3、在upload/themes/mall/default/建立一个test.index.html
admin.php This is to start the ecmall background. After startup, also enter the ecmall framework core file ecmall.php. The subsequent operations are similar to those at the front desk. The difference is that the dispatch center passes the command to the "backstage" control center. But the model called by the controller is the same model center.

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Alipay PHP...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Notepad++7.3.1
Easy-to-use and free code editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),