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

Session 函数 session_cache_limiter 读取/设置缓存限制器

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

      示例1
<?php 
/* 设置缓存限制器为 'private' */
session_cache_limiter('private');
$cache_limiter = session_cache_limiter();
echo "The cache limiter is now set to $cache_limiter<br />";
?>

阅读全文 »

Session 函数 session_reset Re-initialize session array with original values

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

session_reset

(PHP 5 >= 5.6.0, PHP 7, PHP 8)

session_resetRe-initialize session array with original values

说明

session_reset(): bool

session_reset() reinitializes a session with original values stored in session storage. This function requires an active session and discards changes in $_SESSION.

参数

此函数没有参数。

返回值

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

更新日志

版本 说明
7.2.0 The return type of this function is bool now. Formerly, it has been void.

参见

阅读全文 »

Session 函数 session_set_save_handler 设置用户自定义会话存储函数

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

      示例1
<?php 
class MySessionHandler implements SessionHandlerInterface{
    // 在这里实现接口}
$handler = new MySessionHandler();
session_set_save_handler($handler, true);
session_start();
// 现在可以使用 $_SESSION 保存以及获取数据了

阅读全文 »

Session 函数 session_status 返回当前会话状态

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

session_status

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

session_status返回当前会话状态

说明

session_status(): int

session_status() 被用于返回当前会话状态。

返回值

  • PHP_SESSION_DISABLED 会话是被禁用的。
  • PHP_SESSION_NONE 会话是启用的,但不存在当前会话。
  • PHP_SESSION_ACTIVE 会话是启用的,而且存在当前会话。

参见

阅读全文 »

Session 函数 session_set_cookie_params 设置会话 cookie 参数

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

阅读全文 »

Session 函数 session_unset 释放所有的会话变量

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

session_unset

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

session_unset释放所有的会话变量

说明

session_unset(): void

session_unset() 会释放当前会话注册的所有会话变量。

返回值

没有返回值。

注释

注意:

如果使用的是 $_SESSION (或者PHP 4.0.6或更早版本的 $HTTP_SESSION_VARS ) ,请使用 unset() 去 注销会话变量,即 unset ($_SESSION['varname']);.

警告

请不要使用unset($_SESSION)来释放整个$_SESSION, 因为它将会禁用通过全局$_SESSION去注册会话变量

阅读全文 »

Session 函数 session_abort Discard session array changes and finish session

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

session_abort

(PHP 5 >= 5.6.0, PHP 7, PHP 8)

session_abortDiscard session array changes and finish session

说明

session_abort(): bool

session_abort() finishes session without saving data. Thus the original values in session data are kept.

参数

此函数没有参数。

返回值

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

更新日志

版本 说明
7.2.0 The return type of this function is bool now. Formerly, it has been void.

参见

阅读全文 »

Session 函数 session_create_id Create new session id

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

      示例1
<?php 
// My session start function support timestamp managementfunction my_session_start() {
    session_start();
    // Do not allow to use too old session ID    if (!empty($_SESSION['deleted_time']) && $_SESSION['deleted_time'] < time() - 180) {
        session_destroy();
        session_start();
    }
}
// My session regenerate id functionfunction my_session_regenerate_id() {
    // Call session_create_id() while session is active to     // make sure collision free.    if (session_status() != PHP_SESSION_ACTIVE) {
        session_start();
    }
    // WARNING: Never use confidential strings for prefix!    $newid = session_create_id('myprefix-');
    // Set deleted timestamp. Session data must not be deleted immediately for reasons.    $_SESSION['deleted_time'] = time();
    // Finish session    session_commit();
    // Make sure to accept user defined session ID    // NOTE: You must enable use_strict_mode for normal operations.    ini_set('session.use_strict_mode', 0);
    // Set new custom session ID    session_id($newid);
    // Start with custom session ID    session_start();
}
// Make sure use_strict_mode is enabled.// use_strict_mode is mandatory for security reasons.ini_set('session.use_strict_mode', 1);
my_session_start();
// Session ID must be regenerated when//  - User logged in//  - User logged out//  - Certain period has passedmy_session_regenerate_id();
// Write useful codes?>

阅读全文 »

Session 函数 session_cache_expire 返回当前缓存的到期时间

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

      示例1
<?php 
/* 设置缓存限制为 “private” */
session_cache_limiter('private');
$cache_limiter = session_cache_limiter();
/* 设置缓存过期时间为 30 分钟 */
session_cache_expire(30);
$cache_expire = session_cache_expire();
/* 开始会话 */
session_start();
echo "The cache limiter is now set to $cache_limiter<br />";
echo "The cached session pages expire after $cache_expire minutes";
?>

阅读全文 »

Session 函数 session_decode 解码会话数据

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

session_decode

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

session_decode解码会话数据

说明

session_decode(string $data): bool

session_decode()$data 参数中的已经序列化的会话数据进行解码, 并且使用解码后的数据填充 $_SESSION 超级全局变量。

请注意,这里的反序列化方法不同于 unserialize() 函数。 序列化方法是 PHP 内置的,并且可以通过 session.serialize_handler 配置项进行修改。

参数

data

编码后的数据

返回值

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

参见

阅读全文 »

FTP 函数 ftp_nlist 返回给定目录的文件列表

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

      示例1
<?php 
// set up basic connection$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connectionif ((!$conn_id) || (!$login_result)) {
    die("FTP connection has failed !");
}
 // get contents of the root directory$contents = ftp_nlist($conn_id, "/");
// output $contentsvar_dump($contents);
?>

阅读全文 »

FTP 函数 ftp_pasv 返回当前 FTP 被动模式是否打开

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

      示例1
<?php 
$file = 'somefile.txt';
$remote_file = 'readme.txt';
// 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);
// turn passive mode onftp_pasv($conn_id, true);
// upload a fileif (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
 echo "successfully uploaded $file\n";
}
 else {
 echo "There was a problem while uploading $file\n";
}
// close the connectionftp_close($conn_id);
?>

阅读全文 »

FTP 函数 ftp_pwd 返回当前目录名

发表日期:2021-07-01 08:56:47 | 来源: | 分类: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 directory to public_htmlftp_chdir($conn_id, 'public_html');
// print current directoryecho ftp_pwd($conn_id);
 // /public_html// close the connectionftp_close($conn_id);
?>

阅读全文 »

FTP 函数 ftp_put 上传文件到 FTP 服务器

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

      示例1
<?php 
$file = 'somefile.txt';
$remote_file = 'readme.txt';
// 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);
// upload a fileif (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
 echo "successfully uploaded $file\n";
}
 else {
 echo "There was a problem while uploading $file\n";
}
// close the connectionftp_close($conn_id);
?>

阅读全文 »

FTP 函数 ftp_raw 向 FTP 服务器发送命令

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

      示例1
<?php 
$fp = ftp_connect("ftp.example.com");
/* 等同于   ftp_login($fp, "joeblow", "secret");
 */
ftp_raw($fp, "USER joeblow");
ftp_raw($fp, "PASS secret");
?>

阅读全文 »

FTP 函数 ftp_quit ftp_close() 的 别名

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

ftp_quit

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

ftp_quitftp_close() 的 别名

说明

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

阅读全文 »

FTP 函数 ftp_set_option 设置各种 FTP 运行时选项

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

      示例1
<?php 
// 设置网络传输超时时间为 10 秒ftp_set_option($conn_id, FTP_TIMEOUT_SEC, 10);
?>

阅读全文 »

FTP 函数 ftp_nb_continue 连续获取/发送文件(以不分块的方式 non-blocking)

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

      示例1
<?php 
// Initiate the download$ret = ftp_nb_get($my_connection, "test", "README", FTP_BINARY);
while ($ret == FTP_MOREDATA) {
   // Continue downloading...   $ret = ftp_nb_continue($my_connection);
}
if ($ret != FTP_FINISHED) {
   echo "There was an error downloading the file...";
   exit(1);
}
?>

阅读全文 »

FTP 函数 ftp_rename 更改 FTP 服务器上的文件或目录名

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

      示例1
<?php 
$old_file = 'somefile.txt.bak';
$new_file = 'somefile.txt';
// 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);
// try to rename $old_file to $new_fileif (ftp_rename($conn_id, $old_file, $new_file)) {
    echo "successfully renamed $old_file to $new_file\n";
}
 else {
    echo "There was a problem while renaming $old_file to $new_file\n";
}
// close the connectionftp_close($conn_id);
?>

阅读全文 »

FTP 函数 ftp_rawlist 返回指定目录下文件的详细列表

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

      示例1
<?php 
// 初始化连接$conn_id = ftp_connect($ftp_server);
// 使用用户名和密码登录$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// 获取 / 路径下的文件列表$buff = ftp_rawlist($conn_id, '/');
// 关闭连接ftp_close($conn_id);
// 输出var_dump($buff);
?>

阅读全文 »

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