Home > Article > Backend Development > A simple solution to the conflict between __autoload and Smarty in PHP, __autoloadsmarty_PHP tutorial
This article describes a simple solution to the conflict between __autoload and Smarty in PHP. Share it with everyone for your reference, the details are as follows:
1. Question:
Recently, it was discovered in the project that PHP's __autoload method is invalid. 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 has changed 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('ROOT_PATH', dirname(__FILE__)); require_once ROOT_PATH . '/includes/smarty/Smarty.class.php'; spl_autoload_register("__autoload"); // 添加这段代码 ?>
Readers who are interested in more PHP-related content can check out the special topics of this site: "Basic Tutorial for Getting Started with Smarty Templates", "Summary of PHP Template Technology", "Summary of PHP Database Operation Skills Based on PDO", "PHP Operations and Operators" Usage summary", "PHP network programming skills summary", "PHP basic syntax introductory tutorial", "php object-oriented programming introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "Summary of Common Database Operation Skills in PHP"
I hope this article will be helpful to everyone’s PHP program design based on smarty templates.