$out = ""然后再$out .= 与直接 $out=啥的 有什么区别 上面有例子

WBOY
Release: 2016-06-13 13:24:35
Original
945 people have browsed it

$out = ""然后再$out .= 与直接 $out=啥的 有什么区别 下面有例子

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->$fp = @fsockopen($whoisserver, $port, $errno, $errstr, $timeout) or die("Socket Error " . $errno . " - " . $errstr);
    fputs($fp, $domain . "\r\n");
    $out = "";
    while (!feof($fp)){$out .= fgets($fp);}
    fclose($fp);

Copy after login

问下 这里的 
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->$out = "";
    while (!feof($fp)){$out .= fgets($fp);}
Copy after login

于与
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
    while (!feof($fp)){$out= fgets($fp);}
Copy after login


有没区别 区别在哪

------解决方案--------------------
初始化操作,如果不初始化的话 $out的类型是null,与你想要的string不同 ,你可以var_dump看一下

如果用$out来做条件判断的话,不初始化的话,可能会得到不可预料的结果
------解决方案--------------------
$out = "";
while (!feof($fp)){$out .= fgets($fp);}
可以取到$fp文件所有的内容

$out = "";
while (!feof($fp)){$out = fgets($fp);}
取到的是$fp文件最后一行内容
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!