Sandro Antonucci
Sandro Antonucci

Reputation: 1753

php ftp functions response messages

Is it possible with php FTP to get or retrieve the welcome message the server sends?

Something like this you get from FTP clients

Status: Connection established, waiting for welcome message...

Response: 220 Welcome to the OpenDreambox FTP service.

Plus is it possible to get the response code like 220 in that case? Are they even FTP standards those codes?

Upvotes: 4

Views: 783

Answers (2)

Maerlyn
Maerlyn

Reputation: 34105

I don't think you can do it with the ftp_* functions, but there's an alternative approach:

$socket = fsockopen("ftp.microsoft.com", 21); 
echo fgets($socket); //read the welcome line
fclose($socket);

Upvotes: 3

xdazz
xdazz

Reputation: 160883

You can try ftp_raw,

This function Returns the server's response as an array of strings. No parsing is performed on the response string, nor does ftp_raw() determine if the command succeeded.

Upvotes: 2

Related Questions