<code> $router->addRoute('html', new Yaf_Route_Regex('/([a-z]+)\.html$/', array('controller' => 'Index', 'action' => 'html'), array(1 => 'page'))); $router->addRoute('security', new Yaf_Route_Rewrite('security/:name/:rout', array('controller' => 'Security', 'action' => 'html'))); $router->addRoute('trade', new Yaf_Route_Rewrite('trade/:name/:rout', array('controller' => 'Trade', 'action' => 'html'))); </code>
问题一:addRoute第一个参数是后面添加路由的名字么?
问题二:Yaf_Route_Regex('/([a-z]+).html$/', array('controller' => 'Index', 'action' => 'html'), array(1 => 'page')))
三个参数各表示什么?怎么理解这个路由(就是三个参数怎么协调的)?
问题三:Yaf_Route_Rewrite('security/:name/:rout', array('controller' => 'Security', 'action' => 'html')))
三个参数各表示什么(尤其是第一个,强烈表示不解。。)?怎么理解这个路由(就是三个参数怎么协调的)?
回复内容:
<code> $router->addRoute('html', new Yaf_Route_Regex('/([a-z]+)\.html$/', array('controller' => 'Index', 'action' => 'html'), array(1 => 'page'))); $router->addRoute('security', new Yaf_Route_Rewrite('security/:name/:rout', array('controller' => 'Security', 'action' => 'html'))); $router->addRoute('trade', new Yaf_Route_Rewrite('trade/:name/:rout', array('controller' => 'Trade', 'action' => 'html'))); </code>
问题一:addRoute第一个参数是后面添加路由的名字么?
问题二:Yaf_Route_Regex('/([a-z]+).html$/', array('controller' => 'Index', 'action' => 'html'), array(1 => 'page')))
三个参数各表示什么?怎么理解这个路由(就是三个参数怎么协调的)?
问题三:Yaf_Route_Rewrite('security/:name/:rout', array('controller' => 'Security', 'action' => 'html')))
三个参数各表示什么(尤其是第一个,强烈表示不解。。)?怎么理解这个路由(就是三个参数怎么协调的)?
不用yaf,但路由相关的是知道一点的。
参数1,匹配请求地址中的URI部分。例如:
http://www.baidu.com/mobile
,那么这个uri就是mobile,对应到你写的路由就第一个参数。参数2,是数组,controller对应的值是控制器,action是对应的方法。
参数3,也是数组,是请求带过去的参数,例如,page是第几页呀等等。
可以邮件 鸟哥, 他这yaf框架的核心开发者之一。
问题1
<code> $route = new Yaf_Route_Rewrite( "/product/list/:id/", array( "controller" => "product", "action" => "info", ) ); $router->addRoute('dummy', $route);</code>
如果这样添加,名字无所谓,
如果在ini中添加
<code>[routes] routes.product.type='regex' routes.product.match='#^/([0-9]+)[\/]?$#' routes.product.route.module='Product' routes.product.route.controller='product' routes.product.route.action='show' routes.product.map.1='pid'</code>
这样需要读取配置,然后初始化路由
实际上他的名字可以参考路由的5种方式。simplle supervar static【默认】 map rewirte regex
问题2 问题 3 我想你已经知道答案了
tips:这问题如果你去问鸟哥,鸟哥心情好的话会抛给你一份鸟哥语录。
很奇怪,难道不看手册的吗?
8.5. 路由协议详解

tomakephpapplicationsfaster,关注台词:1)useopcodeCachingLikeLikeLikeLikeLikePachetoStorePreciledScompiledScriptbyTecode.2)MinimimiedAtabaseSqueriSegrieSqueriSegeriSybysequeryCachingandeffeftExting.3)Leveragephp7 leveragephp7 leveragephp7 leveragephpphp7功能forbettercodeefficy.4)

到ImprovephPapplicationspeed,关注台词:1)启用opcodeCachingwithapCutoredUcescriptexecutiontime.2)实现databasequerycachingusingpdotominiminimizedatabasehits.3)usehttp/2tomultiplexrequlexrequestsandredececonnection.4 limitsclection.4.4

依赖注入(DI)通过显式传递依赖关系,显着提升了PHP代码的可测试性。 1)DI解耦类与具体实现,使测试和维护更灵活。 2)三种类型中,构造函数注入明确表达依赖,保持状态一致。 3)使用DI容器管理复杂依赖,提升代码质量和开发效率。

databasequeryOptimizationinphpinvolVolVOLVESEVERSEVERSTRATEMIESOENHANCEPERANCE.1)SELECTONLYNLYNESSERSAYCOLUMNSTORMONTOUMTOUNSOUDSATATATATATATATATATATRANSFER.3)

phpisusedforsenderemailsduetoitsbuilt-inmail()函数andsupportiveLibrariesLikePhpMailerandSwiftMailer.1)usethemail()functionforbasicemails,butithasimails.2)butithasimimitations.2)

PHP性能瓶颈可以通过以下步骤解决:1)使用Xdebug或Blackfire进行性能分析,找出问题所在;2)优化数据库查询并使用缓存,如APCu;3)使用array_filter等高效函数优化数组操作;4)配置OPcache进行字节码缓存;5)优化前端,如减少HTTP请求和优化图片;6)持续监控和优化性能。通过这些方法,可以显着提升PHP应用的性能。

依赖性注射(DI)InphpisadesignPatternthatManages和ReducesClassDeptions,增强量产生性,可验证性和Maintainability.itallowspasspassingDepentenciesLikEdenceSeconnectionSeconnectionStoclasseconnectionStoclasseSasasasasareTers,interitationApertatingAeseritatingEaseTestingEasingEaseTeStingEasingAndScalability。

cachingimprovesphpermenceByStorcyResultSofComputationsorqucrouctationsorquctationsorquickretrieval,reducingServerLoadAndenHancingResponsetimes.feftectivestrategiesinclude:1)opcodecaching,whereStoresCompiledSinmememorytssinmemorytoskipcompliation; 2)datacaching datacachingsingMemccachingmcachingmcachings


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器