ThinkPHP里common.php里方法调用有关问题
ThinkPHP里common.php里方法调用问题
我在项目的Common新建了个公共函数文件common.php,在里面写了个 toHtml()方法。
然后在html模板中直接调用 {$list.article_content|toHtml=###}
这样对不对,怎么我在一个小项目里这么执行就可以,
而在另外一个稍微复杂的项目里就说Call to undefined function toHtml() 了呢?
------解决方案--------------------
用标准语法 来调用看看是否调用成功
TP的分组,common.php目录是不同的
------解决方案--------------------
看看该文件是否加载了,然后用原生php代码测试下能否成功。
------解决方案--------------------
2.0的吗?
2.0 的还可用{:function()}
如果不行还可直接用php源码的方式呗
如果加载成功 common.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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
