当前位置:网站首页>php读文件(读取文件内含有某字符串的指定行)
php读文件(读取文件内含有某字符串的指定行)
2022-07-02 05:47:00 【杰儿__er】
文件内容
web=/WmCmUr/WmCmUr?wsdl
audit=/secdit/ws/WmCmUr?wsdl
auth=/app/services/AuthSecService?wsdl
读取含“services”的那一行,且只取等号后的值
/app/services/AuthSecService?wsdl
实现方式:
<?php
$uriFile = "ConfigFile2.conf";
if(file_exists($uriFile))
{
$lines = @file($uriFile);
foreach($lines as $lineStr)
{
//var_dump($lineStr);
/**string(24) "web=/WmCmUr/WmCmUr?wsdl"
string(29) "audit=/secdit/ws/WmCmUr?wsdl"
string(39) "auth=/app/services/AuthSecService?wsdl" */
if(stripos($lineStr, 'services')!==false)
{
var_dump(trim(explode('=', $lineStr)[1]));
}
}
}
?>
显示结果:
[Running] php 2_duwenjian_2.php
string(33) "/app/services/AuthSecService?wsdl"
边栏推荐
猜你喜欢
【技术随记-08】
Fabric. JS iText set italics manually
[personal test] copy and paste code between VirtualBox virtual machine and local
正则表达式总结
How matlab marks' a 'in the figure and how matlab marks points and solid points in the figure
3D 打印机 G 代码命令:完整列表和教程
Brew install * failed, solution
File contains vulnerability (I)
Innovation never stops -- the innovation process of nvisual network visualization platform for Excel import
mysql事务和隔离级别
随机推荐
“简单”的无限魔方
[leetcode] day92 container with the most water
idea开发工具常用的插件合集汇总
Fabric. JS background is not affected by viewport transformation
Taskbar explicit / implicit toggle function
RNN recurrent neural network
Uva548 tree
Huawei Hongmeng OS, is it OK?
Zzuli:1065 count the number of numeric characters
Fabric. JS iText sets the color and background color of the specified text
Fabric. JS 3 APIs to set canvas width and height
1036 Boys vs Girls
数理统计与机器学习
Database batch insert data
JVM class loading mechanism
Innovation never stops -- the innovation process of nvisual network visualization platform for Excel import
2022-2-14 learning xiangniuke project - Section 7 account setting
GRBL 软件:简单解释的基础知识
Win10 copy files, save files... All need administrator permission, solution
XSS basic content learning (continuous update)