Home  >  Article  >  Backend Development  >  Detailed explanation of the solution to the conflict between __autoload and Smarty in PHP

Detailed explanation of the solution to the conflict between __autoload and Smarty in PHP

墨辰丷
墨辰丷Original
2018-06-04 09:57:561444browse

This article mainly introduces the solution to the conflict between __autoload and Smarty in PHP. The method of registering the __autoload function through spl_autoload_register can solve the problem of the __autoload function being invalid in Smarty. Friends in need can refer to it

1. Question:

Recently, it was discovered in the project that PHP's __autoload method failed. After debugging for a long time, I couldn't figure it out. After checking the information, I found out that it was Smarty. The new version of Smarty changes the way autoload is done.

2. Solution:

Add a piece of code after Smarty’s included class file, spl_autoload_register("__autoload");

is as follows:

<?php
  define(&#39;ROOT_PATH&#39;, dirname(__FILE__));
  require_once ROOT_PATH . &#39;/includes/smarty/Smarty.class.php&#39;;
  spl_autoload_register("__autoload"); // 添加这段代码
?>

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

Hide index.php

Detailed explanation of function examples of PHP download files in the ThinkPHP framework

PHP uses the header method to implement the file download function

The above is the detailed content of Detailed explanation of the solution to the conflict between __autoload and Smarty in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn