无需言 做自己 业 ,精于勤 荒于嬉.
- 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): stringlong2ip() 函数通过长整型的表达形式转化生成带点格式的互联网地址(例如:aaa.bbb.ccc.ddd )。
参数
-
proper_address -
合格的地址,长整型的表达形式。
返回值
返回字符串的互联网 IP 地址。
更新日志
版本 说明 7.1.0 参数 proper_address的类型从 string 改成 integer。注释
注意:
在 32 位架构中,从 string 转换 integer 整型形式的 ip 地址将有可能导致错误的结果,因为结果数字超出了
PHP_INT_MAX限制。 -
- 网络 函数 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)
openlog — Open connection to system logger
说明
openlog(string$prefix, int$flags, int$facility): boolopenlog() 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
prefixwill default tofalse.参数
-
prefix -
The string
prefixis added to each message. -
flags -
The
flagsargument is used to indicate what logging options will be used when generating a log message.
You can use one or more of these options. When using multiple options you need toopenlog() Options Constant Description LOG_CONSif there is an error while sending data to the system logger, write directly to the system console LOG_NDELAYopen the connection to the logger immediately LOG_ODELAY(default) delay opening the connection until the first message is logged LOG_PERRORprint log message also to standard error LOG_PIDinclude PID with each message ORthem, 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
facilityargument 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_AUTHsecurity/authorization messages (use LOG_AUTHPRIVinstead in systems where that constant is defined)LOG_AUTHPRIVsecurity/authorization messages (private) LOG_CRONclock daemon (cron and at) LOG_DAEMONother system daemons LOG_KERNkernel messages LOG_LOCAL0...LOG_LOCAL7reserved for local use, these are not available in Windows LOG_LPRline printer subsystem LOG_MAILmail subsystem LOG_NEWSUSENET news subsystem LOG_SYSLOGmessages generated internally by syslogd LOG_USERgeneric user-level messages LOG_UUCPUUCP subsystem 注意:
LOG_USERis 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()的文档。
- 网络 函数 setrawcookie 发送未经 URL 编码的 cookie
-
发表日期:2021-07-01 08:56:42 | 来源: | 分类:网络 函数
-
- 网络 函数 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 | 来源: | 分类:网络 函数
-
说明
此函数是该函数的别名: 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 | 来源: | 分类:网络 函数
-
说明
此函数是该函数的别名: 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 | 来源: | 分类:网络 函数
-
说明
此函数是该函数的别名: 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); ?>
- 前端开发(1)
- 数据库(0)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
- JAVA(0)
- Android(0)
- Linux(0)
- AI大模型(9)
- 其他(0)
宁公网安备 64010402001209号