好!欢迎访问迷津渡口 现在时间是: 天气 °C ~ °C

迷津渡口

越感到迷惑 越接近真理

php教程-autoload和spl_autoload_register

autoload函数

(PHP 5, PHP 7)

定义:

void __autoload(string $class)

作用:

遇到类使用时,自动尝试加载未定义的类。

使用方法:

自定义自动加载的方法,参数为类名,例如

function __autoload($classname) {
    $filename=SITE_ROOT.'/model/'.strtolower($classname).'.php';
    include_once($filename);
}

注意:在文件作用域内只能有一个__autoload函数。

apl_autoload_register函数

(PHP 5 >= 5.1.2, PHP 7)

定义:

bool spl_autoload_register([ callable $autoload_function [, bool $throw = true [, bool $prepend = false ]]])

    参数:

    autoload_function:欲注册的自动装载函数。未设置则自动注册 autoload 的默认实现函数spl_autoload()。

    throw:此参数设置了 autoload_function 无法成功注册时, spl_autoload_register()是否抛出异常。

    prepend:如果是 true,spl_autoload_register() 会添加函数到队列之首,而不是队列尾部

作用:

注册给定的函数作为__autoload函数执行,可注册多个函数,形成__autoload函数序列,默认失败抛出异常,成功注册则添加函数到队列末尾。

使用方法:

定义一个函数,参数为类名,和__autoload一样,但名字不同,然后调用spl_autoload_register注册即可。

注册类的静态函数时,可以使用两种写法,如Example类下的test函数:

// 方法一:数组,第一个值为类名,第二个为函数名
spl_autoload_register(array('Example', 'test'));
// 方法二:使用命名空间法
spl_autoload_register('Example::test');

两种方法作用是一样的。

点赞3
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
financesmiled
 financesmiled 约 5 小时前回复
#202
<a href="http://www.lacosmeticink.com/nike-sb-stefan-janoski-max-mettuttiic-cool-grigio-scarpea">nike sb stefan janoski max mettuttiic cool grigio</a> <a href="http://www.midatlantech.com/new-balance-990-gris-rojo-scarpef">new balance 990 gris rojo</a> <a href="http://www.mjrinfra.com/nike-zoom-pegasus-33-a-buon-mercato-gas-obuvc">nike zoom pegasus 33 a buon mercato gas</a> <a href="http://www.shoppula.com/nike-flyknit-lunar-3-kvinners-gul-gr%C3%A5-scarpea">nike flyknit lunar 3 kvinners gul gr氓</a> <a href="http://www.justdoitperu.com/nike-air-max-2015-sort-r%C3%B8d-bl%C3%A5-chaussuresg">nike air max 2015 sort r酶d bl氓</a> <a href="http://www.kanpourakuen.com/air-jordan-12-hvit-and-gr%C3%A5-kurpesf">air jordan 12 hvit and gr氓</a>
[url=http://www.financesmiled.com/]financesmiled[/url]
uheita
 uheita 约 23 小时前回复
#201
<a href="http://www.noteablepost.com/reebok-gl-6000-white-shoesv">reebok gl 6000 white</a> <a href="http://www.drivedetail.com/nike-hypervenom-order-skow">nike hypervenom order</a> <a href="http://www.jneecedesigns.com/mackage-bryan-down-coat-mackager">mackage bryan down coat</a> <a href="http://www.ametinakar.com/billig-nike-hyperdunk-2015-menns-gr%C3%A5-skod">billig nike hyperdunk 2015 menns gr氓</a> <a href="http://www.planetmolly.com/game-blake-bortles-jersey-jacksonville-jaguars-5-road-white-nfla">game blake bortles jersey jacksonville jaguars 5 road white</a> <a href="http://www.torsenli.com/hermes-belt-price-online-beltr">hermes belt price online</a>
uheita http://www.uheita.com/
unvailevents
 unvailevents 约 23 小时前回复
#200
<a href="http://www.dorinsanat.com/mens-adidas-neo-running-v-racer-low-shoes-skor">mens adidas neo running v racer low shoes</a> <a href="http://www.onpointresale.com/lebron-james-nba-finals-jersey-nflr">lebron james nba finals jersey</a> <a href="http://www.broadcastgg.com/oakland-raiders-15-michael-crabtree-olive-2017-salute-to-service-limited-jersey-nflv">oakland raiders 15 michael crabtree olive 2017 salute to service limited jersey</a> <a href="http://www.andofisch.com/mens-ralph-lauren-pink-shirt-polor">mens ralph lauren pink shirt</a> <a href="http://www.vrpraying.com/billig-nike-hyperdunk-2017-herre-gr%C3%B8n-trainersce">billig nike hyperdunk 2017 herre gr酶n</a> <a href="http://www.jesusinprison.com/ray-ban-original-wayfarer-sale-sunglassesr">ray ban original wayfarer sale</a>
unvailevents http://www.unvailevents.com/
namkala
 namkala 2019-03-19 21:03回复
#199
<a href="http://www.shipmancomm.com/nike-dez-bryant-jersey-nflx">nike dez bryant jersey</a> <a href="http://www.ywutube.com/adidas-samba-primeknit-gr%C3%B8n-brun-kurpesc">adidas samba primeknit gr酶n brun</a> <a href="http://www.bettytatar.com/nike-limited-michael-dickson-jersey-4-nfl-seattle-seahawks-2018-salute-to-service-mens-camo-nflz">nike limited michael dickson jersey 4 nfl seattle seahawks 2018 salute to service mens camo</a> <a href="http://www.eringjewels.com/nike-roshe-run-hyperfuse-or-trophy-match-obuvd">nike roshe run hyperfuse or trophy match</a> <a href="http://www.foremostgold.com/herren-asics-asics-gel-kayano-20-gr%C3%BCn-rot-scarpec">herren asics asics gel kayano 20 gr眉n rot</a> <a href="http://www.galletasmia.com/nike-kobe-9-r%C3%B8d-mamba-lite-kurpesb">nike kobe 9 r酶d mamba lite</a>
namkala http://www.namkala.com/
peddlir
 peddlir 2019-03-19 08:21回复
#198
<a href="http://www.whatoiljobs.com/nike-zoom-winflo-blau-schuhej">nike zoom winflo blau</a> <a href="http://www.mustberavi.com/orlando-magic-new-era-nba-hwc-jacoby-knit-hath">orlando magic new era nba hwc jacoby knit</a> <a href="http://www.dynamixawards.com/nike-free-trainer-3.0-v4-noir-cool-gris-chaussuresh">nike free trainer 3.0 v4 noir cool gris</a> <a href="http://www.nerdalertnews.com/adidas-tubular-radial-schwarz-dam%C3%A4nner-schuheh">adidas tubular radial schwarz dam盲nner</a> <a href="http://www.dmvantalya.com/nike-air-presto-grey-womens-shoesk">nike air presto grey womens</a> <a href="http://www.houshyaree.com/nike-hyperdunk-2014-kvinder-orange-sort-skoj">nike hyperdunk 2014 kvinder orange sort</a>
peddlir http://www.peddlir.com/
jrelselaw
 jrelselaw 2019-03-19 05:35回复
#197
<a href="http://www.atrapaniapp.com/air-jordan-ultra-fly-gul-mintgr%C3%B8n-skok">air jordan ultra fly gul mintgr酶n</a> <a href="http://www.maplebeyond.com/nike-huarache-utility-r%C3%B8d-gr%C3%B8nn-obuvp">nike huarache utility r酶d gr酶nn</a> <a href="http://www.collisionsix.com/mens-nike-zoom-pegasus-32-white-gold-shoesi">mens nike zoom pegasus 32 white gold</a> <a href="http://www.todololitas.com/nike-kd-trey-5-gr%C3%A5-guld-skoj">nike kd trey 5 gr氓 guld</a> <a href="http://www.jcwjrlaw.com/air-jordan-retro-12-kvinners-s%C3%B8lv-hvit-obuvi">air jordan retro 12 kvinners s酶lv hvit</a> <a href="http://www.vstsblog.com/nike-kobe-11-oransje-gr%C3%B8nn-obuvp">nike kobe 11 oransje gr酶nn</a>
jrelselaw http://www.jrelselaw.com/
kyrie 3 bl氓 devil
 kyrie 3 bl氓 devil 2019-03-19 02:28回复
#196
<a href="http://www.immoneyman.com/jordan-11-infrarosso-pictures-kurpesb">jordan 11 infrarosso pictures</a> <a href="http://www.propelrm.com/ray-ban-rb4165-justin-sunglasses-shiny-black-frame-purple-gradie-sunglassesr">ray ban rb4165 justin sunglasses shiny black frame purple gradie</a> <a href="http://www.bonniefineart.com/nike-cincinnati-bengals-16-andrew-hawkins-elite-youth-black-team-color-jersey-nflb">nike cincinnati bengals 16 andrew hawkins elite youth black team color jersey</a> <a href="http://www.donchebike.com/cheap-adidas-porsche-design-skot">cheap adidas porsche design</a> <a href="http://www.landbankcorp.com/nike-lunar-tr1-florida-state-seminoles-trainerse">nike lunar tr1 florida state seminoles</a> <a href="http://www.lamchubanthan.com/adidas-nmd-runner-r%C3%B8d-bl%C3%A5-jordans-chaussuresa">adidas nmd runner r酶d bl氓 jordans</a>
kyrie 3 bl氓 devil http://www.toddystewart.com/kyrie-3-bl%C3%A5-devil-schuhef
alverish
 alverish 2019-03-18 16:27回复
#195
<a href="http://www.joalby.com/nike-air-max-tailwind-6-rouge-argent-obuvf">nike air max tailwind 6 rouge argent</a> <a href="http://www.radiowizi.com/ua-curry-zapatos-marr%C3%B3n-rojo-obuve">ua curry zapatos marr贸n rojo</a> <a href="http://www.rapamateur.com/mennns-nike-kobe-8-system-basketball-sko-kurpesg">mennns nike kobe 8 system basketball sko</a> <a href="http://www.tuartonline.com/jordan-size-us14-us15-brun-sort-obuvb">jordan size us14 us15 brun sort</a> <a href="http://www.bantathlete.com/nike-air-max-95-invigor-print-marr%C3%B3n-negro-butya">nike air max 95 invigor print marr贸n negro</a> <a href="http://www.clandessdiner.com/alfred-morris-jersey-red-nike-t-shirt-nfl-san-francisco-49ers-46-backer-nflu">alfred morris jersey red nike t shirt nfl san francisco 49ers 46 backer</a>
alverish http://www.alverish.com/
clgfamilies
 clgfamilies 2019-03-17 02:38回复
#194
<a href="http://www.mynewsoutlet.com/nike-shox-deliver-wei%C3%9F-herren-you-tube-butya">nike shox deliver wei脽 herren you tube</a> <a href="http://www.yudfdgi.com/nike-philadelphia-eagles-25-tommy-mcdonald-green-backer-long-sleeve-t-shirt-nflu">nike philadelphia eagles 25 tommy mcdonald green backer long sleeve t shirt</a> <a href="http://www.djdiscgolf.com/nike-free-rn-university-rosso-island-kurpesb">nike free rn university rosso island</a> <a href="http://www.guesthousesas.com/dam%C3%A4nner-nike-free-4.0-v3-laufen-schuhe-schwarz-schuhec">dam盲nner nike free 4.0 v3 laufen schuhe schwarz</a> <a href="http://www.lindatompkin.com/nike-huarache-utility-for-verkauf-dalleas-schuheg">nike huarache utility for verkauf dalleas</a> <a href="http://www.marilynbos.com/hommes-nike-roshe-run-high-rose-or-kurpesc">hommes nike roshe run high rose or</a>
clgfamilies http://www.clgfamilies.com/
itsmylogo
 itsmylogo 2019-03-16 13:28回复
#193
<a href="http://www.squigglecase.com/nike-kyrie-2-rouge-queen-chaussuresc">nike kyrie 2 rouge queen</a> <a href="http://www.hshuixin.com/air-jordan-10-retro-wolf-gris-oil-kurpesg">air jordan 10 retro wolf gris oil</a> <a href="http://www.cnnturkcanli.com/mennns-new-balance-574-sonic-gr%C3%B8nn-schuhea">mennns new balance 574 sonic gr酶nn</a> <a href="http://www.milkybeer.com/adidas-zx-flux-independence-day-rot-butyf">adidas zx flux independence day rot</a> <a href="http://www.adsohold.com/wmns-nike-free-tr-flyknit-5.0-rot-silber-kurpesd">wmns nike free tr flyknit 5.0 rot silber</a> <a href="http://www.ashevillewigs.com/jordan-7-azul-blanco-negro-butya">jordan 7 azul blanco negro</a>
itsmylogo http://www.itsmylogo.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸