在discuz中,回帖表(forum_post)中的message欄位中的內容是以如下形式保存的:
$message = "[i=s] u672cu5e16u6700u540eu7531 areyouok u4e8e 2016700u540eu7531 areyouok u4e8e 2016700u540eu7531 areyouok u4e8e 20116-15 ]nn[attach]41[/attach][attach]10[/attach]u592au9633u5149uff0cu91d1u4eaeu4eaeuff0cu96c4u9e21u9ad8u9ad8u5531rn";
4u9e21u9ad8u9ad8u5531rn";? 這裡就需要使用php正規表示式來取得開始字串與結束字串之間的內容,放到一個陣列中一些是測試通過的程式碼:
//取得開始字串後面的一段字元
$subject = '"./uploads/meinian/96140234039638604.html"n"./uploads/meinian/json_30_60393801_20140924.txt"';
$pattern = '#"./uploads/meinian/(.*?)"#i';
$items = preg_match_all($pattern, $subject, $matches);
var_dump($matches);
echo '';
//取得開始字串和結尾字串之間的部分
$subject = "[i=s] u672cu5e16u6700u540eu7531 areyouok u4e8e 2016-3-5 15:12531 areyouok u4e8e 2016-3-5 15:12 u7f16u]fnn91] 41[/attach][attach]10[/attach]u592au9633u5149uff0cu91d1u4eaeu4eaeuff0cu96c4u9e21u9ad8u9ad8u5531d1u4eaeu4eaeuff0cu96c4u9e21u9ad8u9ad8u5531drn";
$pattern = '#[attach](cm tern, $subject , $matches);
$target = preg_replace($pattern,'',$subject);
echo 'target='.$target.'
';
var_dump($matches);
echo '
';
?>
以上就介紹了php正規表示式 取得開始字串和結束字串中的部分內容,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。

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

到ImprovephPapplicationspeed,關注台詞:1)啟用opcodeCachingwithapCutoredUcescriptexecutiontime.2)實現databasequerycachingingusingpdotominiminimizedatabasehits.3)usehttp/2tomultiplexrequlexrequestsandreduceconnection.4 limitesclection.4.4

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

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

phpisusedforsenderemailsduetoitsbuilt-inmail()函數andsupportivelibrariesLikePhpMailerAndSwiftMailer.1)usethemail()functionForbasiceMails,butithasimails.2)butithasimail.2)

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

依賴性注射(DI)InphpisadesignPatternthatManages和ReducesClassDeptions,增強量強制性,可驗證性和MATIALWINABIOS.ItallowSpasspassingDepentenciesLikEdenciesLikedAbaseConnectionStoclasseconnectionStoclasseSasasasasareTers,interitationAseTestingEaseTestingEaseTestingEaseTestingEasingAndScalability。

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 Linux新版
SublimeText3 Linux最新版

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

WebStorm Mac版
好用的JavaScript開發工具

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具