Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5f75b68

Browse files
committed
STDOUT fix
1 parent efe8936 commit 5f75b68

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

‎src/NlpClient.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function get_call($path, $params, $retry = 0)
200200
$this->msg( "NLP API [GET] $path - $url");
201201
$result = @file_get_contents( $url, false );
202202

203-
if ( $http_response_header[0] == 'HTTP/1.0 404 NOT FOUND' )
203+
if ( empty($http_response_header) || $http_response_header[0] == 'HTTP/1.0 404 NOT FOUND' )
204204
return null;
205205

206206
if ( empty($result) || ( isset($http_response_header) && $http_response_header[0] != 'HTTP/1.0 200 OK' ) ) // empty if server is down
@@ -238,10 +238,21 @@ private function msg( $value )
238238
{
239239
if ( is_array($value) )
240240
{
241-
fwrite(STDOUT, print_r( $value, true ) . PHP_EOL );
241+
if(!defined('STDOUT'))
242+
{
243+
print_r( $value );
244+
}else{
245+
fwrite(STDOUT, print_r( $value, true ) . PHP_EOL );
246+
}
242247
}
243-
else
244-
fwrite(STDOUT, $value . PHP_EOL );
248+
else
249+
{
250+
if(!defined('STDOUT')){
251+
echo $value . PHP_EOL;
252+
}else{
253+
fwrite(STDOUT, $value . PHP_EOL );
254+
}
255+
}
245256
}
246257
}
247258

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /