Home Backend Development PHP Tutorial PHP autoload classes

PHP autoload classes

Jul 29, 2016 am 09:06 AM
name quot space span White

<span style="white-space:pre">	</span>方法一:在类外面写
		function __autoload($name){
Copy after login
<span style="white-space:pre">			</span>//处理$name,获得类路径
			include $name_path;
		}
	
	//类内注册
	class ClassA{
Copy after login
<span style="white-space:pre">		</span>public static $_autoload;
		public function __construct(){
			spl_autoload_register(array('ClassA','classAutoLoader'));
		}
		//ClassA 如果实例化可以不用静态方法
		public static function classAutoLoader($name){
			<pre name="code" class="php"><span style="white-space:pre">			</span>//处理$name,获得类路径
			include $name_path;
Copy after login
}}

The above introduces the PHP automatic loading class, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Where is the space key on your computer? Where is the space key on your computer? Feb 22, 2023 am 10:15 AM

The computer space key is at the bottom of the keyboard; the space key is the space bar, or blank key, which is a key on the computer keyboard; the space key is usually a long bar. The main reason for using this design is that it can easily enter spaces, such as in Two words are usually separated by a space, so the space bar is designed to be wider than any other key, allowing the thumbs of both hands to hit the space bar easily.

LEGO bricks constructed from meteorite dust, test run for a moon base LEGO bricks constructed from meteorite dust, test run for a moon base Jun 28, 2024 am 07:25 AM

It is hard to imagine that the building materials for a planned lunar base would first have to be transported to Earth's satellite at great expense. After all, every pound counts when launching from the Earth's surface. The problem is the lunar regol

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

What are the differences between div and span? What are the differences between div and span? Nov 02, 2023 pm 02:29 PM

The differences are: 1. div is a block-level element, and span is an inline element; 2. div will automatically occupy a line, while span will not automatically wrap; 3. div is used to wrap larger structures and layouts, and span is used to wrap Text or other inline elements; 4. div can contain other block-level elements and inline elements, and span can contain other inline elements.

How to add name to setup in Vue3 How to add name to setup in Vue3 May 13, 2023 am 09:40 AM

What is the use of name in Vue3? 1. Name needs to be defined when making recursive components. 2. The component can be cached with keep-aliveincludeexclude. 3. When Vue reports an error or is debugging, you can see the name of the component. Vue3 defines name1. It is automatically generated as long as the setup syntax sugar mode single file component is turned on in the script. The corresponding name option will be automatically generated based on the file name. For example, Tree.vue, then its name will be automatically generated by Tree. This has a drawback. If you want to modify the name, you need to modify the component name. If there is a place to import the component, you need to modify it together. 2. Open a script to define name

What does span mean in html? What does span mean in html? Apr 28, 2021 pm 02:30 PM

span in html is a tag used to combine inline elements in the document; the <span> tag does not have a fixed format, and it will only produce visual changes when a style is applied to it; if the <span> tag is not used Apply the style so that the text in the <span> element will not be visually different from other text.

How to add a swap partition to a Linux system How to add a swap partition to a Linux system Jan 03, 2024 am 10:18 AM

Does the swap space feel like the virtual memory of Linux? When the memory is not enough, certain technical means are used to temporarily store some things in the physical memory that have not been used for a long time in this space and then empty it. Some memory is released for the program to use. The method of adding is very simple. First, you need superuser identity (add sudo or sudosu- before the command). First, sudoddif=/dev/zeroof=/swapfilebs=1024count=1048576/dev/zero file represents a device file that always outputs 0. Use it as input. You can get a completely empty file. Therefore can be used to create new files and clear them by overwriting

What should I do if php cannot get the name? What should I do if php cannot get the name? Nov 24, 2022 am 09:56 AM

PHP cannot get the name because when the name and id values ​​of the form element are different, the browser cannot recognize it. The solution: 1. Check whether some form elements and frame elements use name; 2. Check only Elements that can be assigned ID but not name; 3. For multi-select box checkbox, you can use "join(',', $__POST['name'])" to form data.

See all articles