Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What about the failure of _ _ autoload in php

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "what to do with the failure of _ _ autoload in php". In the daily operation, I believe that many people have doubts about the failure of _ _ autoload in php. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful for you to answer the question of "what to do with the failure of _ _ autoload in php"! Next, please follow the editor to study!

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

What if php _ _ autoload fails?

Failure reason of PHP function _ _ autoload (related to smarty)

The PHP function _ _ autoload can achieve simple automatic loading, but after the introduction of smarty, it is found that the _ _ autoload function is invalid, which is later found to be the cause of the spl_autoload_register function.

Execute the following code:

Function _ _ autoload ($name) {require 'class/'.$name.'.php';echo' 1percent;} function autoload_test ($name) {echo '2percent;} spl_autoload_register (' autoload_test'); $ca=new Ca ()

Result output 2, you can see that the _ _ autoload function is not executed. The parsing on the official website is: if the _ _ autoload () function has been implemented in your program, it must be explicitly registered in the _ _ autoload () queue. Because the spl_autoload_register () function replaces the _ _ autoload () function in Zend Engine with spl_autoload () or spl_autoload_call ().

In order for the code to work properly, you should re-register the _ _ autoload function:

Function _ _ autoload ($name) {require 'class/'.$name.'.php';echo' 1century;} function autoload_test ($name) {echo '2customers;} spl_autoload_register (' autoload_test'); spl_autoload_register ('_ autoload'); $ca=new Ca (); at this point, the study of "what to do with the failure of _ _ autoload in php" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report