【问题标题】:PHP Script fopen failed to open stream: > Invalid argument ErrorPHP 脚本 fopen 无法打开流:> 无效参数错误
【发布时间】:2013-04-25 01:06:12
【问题描述】:

我收到警告。

警告:fopen(76561197992146126 .txt):无法打开流: 第 6 行 C:\wamp\www\Download\t3.php 中的参数无效

对于任何想知道的人,这是下面 main.txt 的内容 (http://pastebin.com/53chSRRz)

<?php
    $APIkey = 'APIKeyHere';
    $file = file('C:\wamp\www\Download\main.txt');
    foreach ($file as $link) { 
    $link2 = "http://api.steampowered.com/ITFItems_440/GetPlayerItems/v0001/?key=" . $APIkey . "&SteamID=" . $link . "&format=json";
    $downloaded = file_get_contents($link2);
    $fh = fopen($link . ".txt", "a"); //or die("can't open file");
    fwrite($fh, $downloaded);
    }
    echo "Finished";
?>

如果我将 "fopen($link . ".txt", "a")" 替换为静态文件名,它就可以工作。但我需要 $link 作为文件名。这对我的设置至关重要。

我正在使用 WAMP 2.2 和 PHP 5.4.3 运行 Windows 7 x64

【问题讨论】:

    标签: php fopen


    【解决方案1】:

    您的链接 ID 中有空格。尝试在创建 $link2 之前添加 $link = trim($link);

    【讨论】:

    • 神圣的废话。你不知道我花了多长时间来修复这条细线。非常感谢xD
    猜你喜欢
    • 1970-01-01
    • 2016-05-06
    • 2015-09-28
    • 2019-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-02
    • 1970-01-01
    相关资源
    最近更新 更多