我正在使用以下内容返回服务器上所有文本文件的列表。
echo json_encode(glob("*.{txt}", GLOB_BRACE));
我遇到的问题是,当我从我的应用程序执行这个 php 文件时,目录中只有一个文本文件,它按预期返回文件名的 JSON,但是当我重命名该文本文件或添加其他文件时,它会继续仅返回原始运行时存在的文件的名称。
我对 PHP 很陌生,我想知道我是否返回缓存数据而不是每次都刷新,或者这可能是我的应用程序发生的情况。
这是应用程序代码:
NSURLSessionDataTask *getTheFileList = [session dataTaskWithURL:[NSURL URLWithString:@"http://www.myserver.com/utility/listJSON2.php"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSEnumerator *enumerator = [json objectEnumerator];
id value;
while ((value = [enumerator nextObject]))
{
/* code that acts on the dictionary’s values */
NSLog(@"text file name: %@", value);
}
}];
谢谢!