无需言 做自己 业 ,精于勤 荒于嬉.

FTP 函数 ftp_chdir 在 FTP 服务器上改变当前目录

发表日期:2021-07-01 08:56:46 | 来源: | 分类:FTP 函数

      示例1
<?php 
// set up basic connection$conn_id = ftp_connect($ftp_server);
// login with username and password$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connectionif ((!$conn_id) || (!$login_result)) {
    die("FTP connection has failed !");
}
echo "Current directory: " . ftp_pwd($conn_id) . "\n";
// try to change the directory to somedirif (ftp_chdir($conn_id, "somedir")) {
    echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
}
 else {
    echo "Couldn't change directory\n";
}
// close the connection ftp_close($conn_id);
 ?>

阅读全文 »

FTP 函数 ftp_nb_get 从 FTP 服务器上获取文件并写入本地文件(non-blocking)

发表日期:2021-07-01 08:56:46 | 来源: | 分类:FTP 函数

      示例1
<?php 
// 初始化$ret = ftp_nb_get($my_connection, "test", "README", FTP_BINARY);
while ($ret == FTP_MOREDATA) {
      // 可以同步干其它事   echo ".";
   // 继续下载...   $ret = ftp_nb_continue($my_connection);
}
if ($ret != FTP_FINISHED) {
   echo "下载文件出错...";
   exit(1);
}
?>

      示例2
<?php 
// 初始化 $ret = ftp_nb_get($my_connection, "test", "README", FTP_BINARY,                       filesize("test"));
// OR: $ret = ftp_nb_get($my_connection, "test", "README", //                           FTP_BINARY, FTP_AUTORESUME);
while ($ret == FTP_MOREDATA) {
      // 做你爱做的事   echo ".";
   // 继续下载Ing...   $ret = ftp_nb_continue($my_connection);
}
if ($ret != FTP_FINISHED) {
   echo "下载文件出错...";
   exit(1);
}
?>

      示例3
<?php 
// 禁止 Autoseekftp_set_option($my_connection, FTP_AUTOSEEK, false);
// 初始化$ret = ftp_nb_get($my_connection, "newfile", "README", FTP_BINARY, 100);
while ($ret == FTP_MOREDATA) {
   /* ... */
      // 继续下载...   $ret = ftp_nb_continue($my_connection);
}
?>

阅读全文 »

FTP 函数 ftp_alloc 为要上传的文件分配空间

发表日期:2021-07-01 08:56:45 | 来源: | 分类:FTP 函数

      示例1
<?php 
$file = "/home/user/myfile";
// 连接服务器$conn_id = ftp_connect('ftp.example.com');
$login_result = ftp_login($conn_id, 'anonymous', 'user@example.com');
if (ftp_alloc($conn_id, filesize($file), $result)) {
  echo "Space successfully allocated on server.  Sending $file.\n";
  ftp_put($conn_id, '/incomming/myfile', $file, FTP_BINARY);
}
 else {
  echo "Unable to allocate space on server.  Server said: $result\n";
}
ftp_close($conn_id);
?>

阅读全文 »

FTP 函数 ftp_cdup 切换到当前目录的父目录

发表日期:2021-07-01 08:56:45 | 来源: | 分类:FTP 函数

      示例1
<?php 
 // set up basic connection $conn_id = ftp_connect($ftp_server);
 // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
 // change the current directory to html ftp_chdir($conn_id, 'html');
 echo ftp_pwd($conn_id);
 // /html // return to the parent directory if (ftp_cdup($conn_id)) {
   echo "cdup successful\n";
 }
 else {
   echo "cdup not successful\n";
 }
 echo ftp_pwd($conn_id);
 // / ftp_close($conn_id);
 ?>

阅读全文 »

FTP 函数 ftp_chmod 设置 FTP 服务器上的文件权限

发表日期:2021-07-01 08:56:45 | 来源: | 分类:FTP 函数

      示例1
<?php 
$file = 'public_html/index.php';
// 建立基础连接$conn_id = ftp_connect($ftp_server);
// 使用用户名和密码登录$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// 尝试设置 $file 的权限为 644if (ftp_chmod($conn_id, 0644, $file) !== false) {
 echo "$file chmoded successfully to 644\n";
}
 else {
 echo "could not chmod $file\n";
}
// 关闭连接ftp_close($conn_id);
?>

阅读全文 »

FTP 函数 ftp_append 将文件内容追加到 FTP 服务器上的指定文件

发表日期:2021-07-01 08:56:45 | 来源: | 分类:FTP 函数

ftp_append

(PHP 7 >= 7.2.0, PHP 8)

ftp_append将文件内容追加到 FTP 服务器上的指定文件

说明

ftp_append(
    resource $ftp,
    string $remote_filename,
    string $local_filename,
    int $mode = FTP_BINARY
): bool

警告

本函数还未编写文档,仅有参数列表。

参数

ftp

remote_filename

local_filename

mode

返回值

成功时返回 true, 或者在失败时返回 false

阅读全文 »

网络 函数 long2ip 将长整型转化为字符串形式带点的互联网标准格式地址(IPV4)

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

long2ip

(PHP 4, PHP 5, PHP 7, PHP 8)

long2ip将长整型转化为字符串形式带点的互联网标准格式地址(IPV4)

说明

long2ip(int $proper_address): string

long2ip() 函数通过长整型的表达形式转化生成带点格式的互联网地址(例如:aaa.bbb.ccc.ddd )。

参数

proper_address

合格的地址,长整型的表达形式。

返回值

返回字符串的互联网 IP 地址。

更新日志

版本 说明
7.1.0 参数 proper_address 的类型从 string 改成 integer

注释

注意:

在 32 位架构中,从 string 转换 integer 整型形式的 ip 地址将有可能导致错误的结果,因为结果数字超出了 PHP_INT_MAX 限制。

参见

  • ip2long() - 将 IPV4 的字符串互联网协议转换成长整型数字

阅读全文 »

网络 函数 inet_pton Converts a human readable IP address to its packed in_addr representation

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

      示例1
<?php 
$in_addr = inet_pton('127.0.0.1');
 $in6_addr = inet_pton('::1');
?>

阅读全文 »

网络 函数 inet_ntop Converts a packed internet address to a human readable representation

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

      示例1
<?php 
$packed = chr(127) . chr(0) . chr(0) . chr(1);
$expanded = inet_ntop($packed);
/* Outputs: 127.0.0.1 */
echo $expanded;
$packed = str_repeat(chr(0), 15) . chr(1);
$expanded = inet_ntop($packed);
/* Outputs: ::1 */
echo $expanded;
?>

阅读全文 »

网络 函数 openlog Open connection to system logger

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

openlog

(PHP 4, PHP 5, PHP 7, PHP 8)

openlogOpen connection to system logger

说明

openlog(string $prefix, int $flags, int $facility): bool

openlog() opens a connection to the system logger for a program.

The use of openlog() is optional. It will automatically be called by syslog() if necessary, in which case prefix will default to false.

参数

prefix

The string prefix is added to each message.

flags

The flags argument is used to indicate what logging options will be used when generating a log message.

openlog() Options
Constant Description
LOG_CONS if there is an error while sending data to the system logger, write directly to the system console
LOG_NDELAY open the connection to the logger immediately
LOG_ODELAY (default) delay opening the connection until the first message is logged
LOG_PERROR print log message also to standard error
LOG_PID include PID with each message
You can use one or more of these options. When using multiple options you need to OR them, i.e. to open the connection immediately, write to the console and include the PID in each message, you will use: LOG_CONS | LOG_NDELAY | LOG_PID

facility

The facility argument is used to specify what type of program is logging the message. This allows you to specify (in your machine's syslog configuration) how messages coming from different facilities will be handled.

openlog() Facilities
Constant Description
LOG_AUTH security/authorization messages (use LOG_AUTHPRIV instead in systems where that constant is defined)
LOG_AUTHPRIV security/authorization messages (private)
LOG_CRON clock daemon (cron and at)
LOG_DAEMON other system daemons
LOG_KERN kernel messages
LOG_LOCAL0 ... LOG_LOCAL7 reserved for local use, these are not available in Windows
LOG_LPR line printer subsystem
LOG_MAIL mail subsystem
LOG_NEWS USENET news subsystem
LOG_SYSLOG messages generated internally by syslogd
LOG_USER generic user-level messages
LOG_UUCP UUCP subsystem

注意:

LOG_USER is the only valid log type under Windows operating systems

返回值

成功时返回 true, 或者在失败时返回 false

参见

阅读全文 »

网络 函数 pfsockopen 打开一个持久的网络连接或者Unix套接字连接。

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

pfsockopen

(PHP 4, PHP 5, PHP 7, PHP 8)

pfsockopen打开一个持久的网络连接或者Unix套接字连接。

说明

pfsockopen(
    string $hostname,
    int $port = -1,
    int &$errno = ?,
    string &$errstr = ?,
    float $timeout = ini_get("default_socket_timeout")
): resource

这个函数的作用与fsockopen()完全一样的,不同的地方在于当在脚本执行完后,连接一直不会关闭。可以说它是fsockopen()的长连接版本。

参数

对于其参数的信息,请参考fsockopen()的文档。

参见

  • fsockopen() - 打开一个网络连接或者一个Unix套接字连接

阅读全文 »

网络 函数 setrawcookie 发送未经 URL 编码的 cookie

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

setrawcookie

(PHP 5, PHP 7, PHP 8)

setrawcookie发送未经 URL 编码的 cookie

说明

setrawcookie(
    string $name,
    string $value = ?,
    int $expire = 0,
    string $path = ?,
    string $domain = ?,
    bool $secure = false,
    bool $httponly = false
): bool

setrawcookie()setcookie() 非常相似,唯一不同之处是发送到浏览器的 cookie 值没有自动经过 URL 编码(urlencode)。

参数

相关参数的信息参见 setcookie() 的文档。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
5.5.0 发送给客户端的 Set-Cookie 头现在会加上 Max-Age 属性。
5.2.0 增加了 httponly 参数。

参见

阅读全文 »

网络 函数 setcookie 发送 Cookie

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

      示例1
<?php 
$value = 'something from somewhere';
setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+3600);
  /* 1 小时过期  */
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1);
?>

      示例2
<?php 
// 打印一个单独的 Cookieecho $_COOKIE["TestCookie"];
//  debug/test 查看所有 Cookie 的另一种方式print_r($_COOKIE);
?>

      示例3
<?php 
// 设置过期时间为一个小时前setcookie("TestCookie", "", time() - 3600);
setcookie("TestCookie", "", time() - 3600, "/~rasmus/", "example.com", 1);
?>

      示例4
<?php 
// 设置 Cookiesetcookie("cookie[three]", "cookiethree");
setcookie("cookie[two]", "cookietwo");
setcookie("cookie[one]", "cookieone");
// 网页刷新后,打印出以下内容if (isset($_COOKIE['cookie'])) {
    foreach ($_COOKIE['cookie'] as $name => $value) {
        $name = htmlspecialchars($name);
        $value = htmlspecialchars($value);
        echo "$name : $value <br />\n";
    }
}
?>

阅读全文 »

网络 函数 socket_set_timeout 别名 stream_set_timeout()

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

socket_set_timeout

(PHP 4, PHP 5, PHP 7, PHP 8)

socket_set_timeout别名 stream_set_timeout()

说明

此函数是该函数的别名: stream_set_timeout()

阅读全文 »

网络 函数 ip2long 将 IPV4 的字符串互联网协议转换成长整型数字

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

      示例1
<?php 
$ip = gethostbyname('www.example.com');
$out = "The following URLs are equivalent:<br />\n";
$out .= 'http://www.example.com/, http://' . $ip . '/, and http://' . sprintf("%u", ip2long($ip)) . "/<br />\n";
echo $out;
?>

      示例2
<?php 
$ip   = gethostbyname('www.example.com');
$long = ip2long($ip);
if ($long == -1 || $long === FALSE) {
    echo 'Invalid IP, please try again';
}
 else {
    echo $ip   . "\n";
           // 192.0.34.166    echo $long . "\n";
           // -1073732954    printf("%u\n", ip2long($ip));
 // 3221234342}
?>

阅读全文 »

网络 函数 socket_set_blocking 别名 stream_set_blocking()

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

socket_set_blocking

(PHP 4, PHP 5, PHP 7, PHP 8)

socket_set_blocking别名 stream_set_blocking()

说明

此函数是该函数的别名: stream_set_blocking()

阅读全文 »

网络 函数 syslog Generate a system log message

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

      示例1
<?php 
// open syslog, include the process ID and also send// the log to standard error, and use a user defined// logging mechanismopenlog("myScriptLog", LOG_PID | LOG_PERROR, LOG_LOCAL0);
// some codeif (authorized_client()) {
    // do something}
 else {
    // unauthorized client!    // log the attempt    $access = date("Y/m/d H:i:s");
    syslog(LOG_WARNING, "Unauthorized client: $access {
$_SERVER['REMOTE_ADDR']}
 ({
$_SERVER['HTTP_USER_AGENT']}
)");
}
closelog();
?>

阅读全文 »

网络 函数 socket_get_status 别名 stream_get_meta_data()

发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数

socket_get_status

(PHP 4, PHP 5, PHP 7, PHP 8)

socket_get_status别名 stream_get_meta_data()

说明

此函数是该函数的别名: stream_get_meta_data()

阅读全文 »

网络 函数 gethostbyname 返回主机名对应的 IPv4地址。

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
$ip = gethostbyname('www.example.com');
echo $ip;
?>

阅读全文 »

网络 函数 gethostbynamel 获取互联网主机名对应的 IPv4 地址列表

发表日期:2021-07-01 08:56:41 | 来源: | 分类:网络 函数

      示例1
<?php 
$hosts = gethostbynamel('www.example.com');
print_r($hosts);
?>

阅读全文 »

全部博文(1589)
集速网 copyRight © 2015-2025 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。