1

我有一段 php 代码,在页面加载请求时会找到一个相应的文件,其中包含有关页面的信息,包括密码。

文件中的语法如下:

Pagename: 
PageInfo:
Password: SecretPassword 

我如何才能找到密码后面的密码:?

我的 PHP 代码如下所示:

$filepath = absolute_url("page/info.php");  
$infoFile = fopen("$filepath", "r");
$contents = stream_get_contents($infoFile);
4

1 回答 1

0

似乎是一种非常奇怪的数据存储方式。假设这无济于事,您可以使用以下方式进行 RegEx:

$matches = array();
preg_match('/Password:\s(.*)$/', $contents, $matches);
//                     ^ Assuming there's only ever 1 space

echo $matches[1]将打印SecretPassword

于 2013-03-31T15:03:20.047 回答