问题标签 [unset]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
4456 浏览

php - Destroy session, but keep one variable set

I am using session variables to control logins and page access. I use variables to control different user groups that a user belongs to, so I have quite a few session variables.

I also use a session variable to remember the users last visited page upon refresh.

When the user logs out, I use session_destroy(); to remove all variables. What i would like to do is to maintain the last visited page variable even after the user has logged out.

I think I could do it by using the unset function on every other variable, but there are a lot, and was wondering if there was an easier way?

Thanks Eds

0 投票
9 回答
19174 浏览

php - Smarty:取消设置模板中的数组索引

我想做{unset($array['index'])}一个Smarty 3模板。

是否支持这样的语法(或类似的)?在谷歌搜索和文档阅读之后,我找不到令人满意的东西。

也许我应该向 Smarty 开发团队提出功能请求?:)

无论如何,鉴于当前可用的模板功能,您将如何做到这一点?

0 投票
1 回答
599 浏览

php - 未设置时的php会话变量问题

我已经创建了一个函数来设置会话变量 $_SESSION['flash'] 以便在页面之间存储消息

以及打印此消息的功能

我在每一页的顶部调用这个函数(当然在 session_start 之后)

问题是它什么都不打印,但是如果我评论“ unset($_SESSION['flash']);” 它在每一页打印消息。

我该如何解决?


解决了对不起我的错。

现在我将 printFlash 直接放在我的页面中并且可以正常工作..bah 奇怪...我的错误是什么?

0 投票
5 回答
1330 浏览

php - PHP数组未设置字符串

我正在尝试取消设置一组具有相同前缀的数组键。我似乎无法让它工作。

我如何才能看到 ['prefix_' 。$key] 作为实际变量?谢谢

更新: $array 键将有两个具有相同名称的键。只有一个具有前缀,并且大约有 5 个带有前缀键的键:

我不想从数组中删除 [name] 只是 [prefix_name]。

0 投票
1 回答
436 浏览

php - 取消设置 php 计数

我在我创建的每个站点的底部都有这个运行。因为它循环我需要取消设置值。我试图尽可能地节省内存

0 投票
8 回答
6730 浏览

php - 从当前函数中取消设置所有定义的变量

例如,我有这个功能:

那么,我可以在需要点之前取消设置所有这些变量吗?

显然没有在每个变量上手动调用 unset ,因为我自己发现了:)

有什么功能可以做到这一点吗?

0 投票
2 回答
4428 浏览

php - Codeigniter 会话不会取消设置

我在一个社区工作,我想用户注销,但它没有设置用户数据:S,你知道为什么吗?

这是我的控制器功能

0 投票
3 回答
127 浏览

php - 取消设置许多数组

我的代码需要帮助。从下面的数组中取消设置 xfer 数组:



我只是:



并取消所有 3 我这样做。更新 - 实际上我在“字段”中有很多数组,但我只提供了 3 个:



无论如何我可以在不 unset($form["tabs"]['dns_soa']['fields']array name here);多次编码的情况下取消设置许多数组吗?提前致谢。

更新 - 很抱歉,我应该提供更多信息。如何禁用 3 个阵列中的 2 个?例如只禁用 ['xfer'] 和 ['active']?

0 投票
2 回答
181 浏览

php - 未设置会话变量会停止执行

我一直在为这段代码发疯,并将其缩小到未设置的功能。当我在会话变量上调用 unset 时,PHP 不会执行任何超出该点的操作。有人可以帮忙吗?

我调用打印通知::print_session_notification(); 从标题包含。标头包含由函数调用。$notification 对象在调用头文件的函数中是全局的。

0 投票
3 回答
3740 浏览

jquery - jQuery: best practice for unsetting / removing function events?

I'm using the jQuery plugin Cloud Zoom, and I've altered the initialization so that the image is zoomed when the user clicks on a "magnify button" instead of hovering. I'm not sure how to unset/remove this event when the user leaves the image though, and I'd be very interested to hear what the best practice would be.

This is what the script looks like -

(".display" is a container) Is bind/unbind necessary? It seems it might do the trick, but I wish there was an easier method since it's just about one function.