adding examples proposed by vincent at php dot net

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@138087 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Mehdi Achour 2003-08-17 13:14:23 +00:00
parent 23396d4d4e
commit 3b5d36de26
6 changed files with 176 additions and 6 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.32 -->
<refentry id='function.ftp-exec'>
<refnamediv>
@ -18,6 +18,31 @@
server. Returns &true; if the command was successful (server sent response code:
<literal>200</literal>); otherwise returns &false;.
</para>
<para>
<example>
<title><function>ftp_exec</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$command = 'ls -al';
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if($res = ftp_exec($conn_id, $command)) {
echo "$command executed successfully<br />\n";
echo nl2br($res);
} else {
echo 'could not execute ' . $command;
}
?>
]]>
</programlisting>
</example>
</para>
<para>
See also <function>ftp_raw</function>.
</para>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-fput">
<refnamediv>
@ -23,6 +23,37 @@
<parameter>mode</parameter> specified must be either
<constant>FTP_ASCII</constant> or <constant>FTP_BINARY</constant>.
</para>
<para>
<example>
<title><function>ftp_fput</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// open some file for reading
$file = 'somefile.txt';
$fp = fopen($file, 'r');
// connect to the server
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to upload the file
if(ftp_fput($conn_id, $file, $fp, FTP_ASCII)) {
echo "Successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
// close the connection and the file handler
ftp_close($conn_id);
fclose($fp);
?>
]]>
</programlisting>
</example>
</para>
<note>
<para>
The <parameter>startpos</parameter> parameter was added in PHP 4.3.0.

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-get">
<refnamediv>
@ -31,6 +31,36 @@
<para>
&return.success;
</para>
<para>
<example>
<title><function>ftp_get</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// define some variables
$local_file = 'local.zip';
$server_file = 'server.zip';
// connect to the FTP server
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to download
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}
// close the connection
ftp_close($conn_id);
?>
]]>
</programlisting>
</example>
</para>
<para>
See also <function>ftp_fget</function>, <function>ftp_nb_get</function> and
<function>ftp_nb_fget</function>.

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-mdtm">
<refnamediv>
@ -21,6 +21,37 @@
<para>
Returns a UNIX timestamp on success, or -1 on error.
</para>
<para>
<example>
<title></title>
<programlisting role="php">
<![CDATA[
<?php
$file = 'somefile.txt';
// connect to the server
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// get the last modified time
$buff = ftp_mdtm($conn_id, $file);
if ($buff != -1) {
// somefile.txt was last modified on: March 26 2003 14:16:41.
echo "$file was last modified on : " . date ("F d Y H:i:s.", $buff);
} else {
echo "Couldn't get mdtime";
}
// close the connection
ftp_close($conn_id);
?>
]]>
</programlisting>
</example>
</para>
<note>
<para>
Not all servers support this feature!

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-rmdir">
<refnamediv>
@ -21,6 +21,31 @@
<para>
&return.success;
</para>
<para>
<example>
<title><function>ftp_rmdir</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$dir = 'www/';
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (ftp_rmdir($conn_id, $dir)) {
echo 'Successfully deleted ' . $dir;
} else {
echo 'There was a problem while deleting ' . $dir;
}
ftp_close($conn_id);
?>
]]>
</programlisting>
</example>
</para>
<para>
See also <function>ftp_mkdir</function>.
</para>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-size">
<refnamediv>
@ -22,6 +22,34 @@
<para>
Returns the file size on success, or -1 on error.
</para>
<para>
<example>
<title><function>ftp_size</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$file = 'somefile.txt';
// connect to the server
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$res = ftp_size($conn_id, $file);
if ($res != -1) {
echo "size of $file is $res bytes";
} else {
echo "couldn't get the size";
}
ftp_close($conn_id);
?>
]]>
</programlisting>
</example>
</para>
<para>
See also <function>ftp_rawlist</function>.
</para>