问题标签 [php-5.4]

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 投票
1 回答
53 浏览

php - 用数组内的参数闭包

我在 PHP 5.4 中遇到了关闭问题

我有数组

当我使用

有用。但我不知道如何将 min 与参数一起使用,例如 3

我试过了

不工作。

0 投票
3 回答
13475 浏览

php - Opcache - 在 PHP5.4 及更低版本中清理缓存

有没有办法使用PHP5.4 或更低版本的 Opcache 清理/重置缓存文件?
opcache_reset()似乎只适用于 PHP5.5的函数

解决方法是重新启动...

编辑:我在 Github 上打开了一个问题

0 投票
1 回答
106 浏览

cakephp - 在路由和框架 .html 页面中包含 GET 参数

我有一个以 GET 形式提交数据的表单

这意味着,当我这样做时:

我得到的网址为:example.com/Searches/results?search=asdadasdasd

我想构建路由,以便获得以下 URL:

example.com/search/asdadasdasd.html

我看了看:http ://book.cakephp.org/2.0/en/development/routing.html

我知道如何获得扩展名:http: //book.cakephp.org/2.0/en/development/routing.html#file-extensions

但是,我将如何在里面获取搜索查询?

谢谢

0 投票
3 回答
593 浏览

php - 基本的 PHP 语法或配置?脚本不在 WAMP 服务器上执行

我正在尝试编写一个简单的 PHP 脚本:

  1. 用户访问网页并通过表单注册他们的电子邮件地址和密码(无需其他输入)。
  2. 他们的电子邮件和密码存储在数据库中,并生成随机唯一的 6 位密码并存储在电子邮件中。该引脚会根据数据库中的现有引脚进行检查,以确保它是唯一的。
  3. 然后,该密码将显示在网页上,并在确认用户提交的电子邮件和密码后显示给用户。

TL;DR 用户注册并获得一个独特的密码。

我有以下 PHP 代码,但它似乎没有在我的 WAMP 服务器上执行。它只是将 .php 页面作为原始文本返回。我是否缺少一些明显的语法或配置?

0 投票
2 回答
3006 浏览

php - 如何在 PHP 中创建随机唯一的字母数字字符串

我有以下代码,可让用户使用密码在网站上注册他/她的电子邮件,并向他们返回一个唯一的 pin。

我想为每个用户关联一个唯一的 URL(server.com/[unique-9-digit-alphanumeric-code],这样我就可以创建一个相对安全的管理页面,用户无需知道密码即可访问。

有没有一种简单的方法可以使用 PHP 函数(它不必是 9 位数字,只需长且随机),还是我需要生成自己的随机字母数字字符串,然后将其发布到数据库?您如何建议对此进行编码?

0 投票
3 回答
1937 浏览

php - 在 PHP 中使用 while() 并继续

我正在学习 PHP 并尝试正确使用 while 和 continue 表达式。

我有一个创建 6 位 PIN 的脚本,我想确保它是唯一的,否则我想生成另一个 PIN。

我的循环语法是否正确?它似乎有效,但我无法在 rand() 函数两次创建相同 PIN 的实例中对其进行调试。

此外,如果我确实用完了唯一 PIN,这里会发生什么?大概它会无限循环?有什么办法可以防止这种情况发生吗?

0 投票
1 回答
7052 浏览

php - PHP Memory Allocation and Deallocation

So, I am running a long-running script that is dealing with memory sensitive data (large amounts of it). I (think) I am doing a good job of properly destroying large objects throughout the long running process, to save memory.

I have a log that continuously outputs current memory usage (using memory_get_usage()), and I do not notice rises and drops (significant ones) in memory usage. Which tells me I am probably doing the right thing with memory management.

However, if I log on to the server and run a top command, I notice that the apache process that is dealing with this script never deallocates memory (at least visibly though the top command). It simply remains at the highest memory usage, even if the current memory usage reported by php is much, much lower.

So, my question is: are my attempts to save memory futile if the memory isnt really being freed back to the server? Or am I missing something here.

Thank you.

ps. using php 5.4 on linux

pps. For those who want code, this is a basic representation:

update: as hek2mgl recommended, I ran debug_zval_dump(), and the output, to me, seems correct.

Output:

0 投票
1 回答
66 浏览

oop - 格式化时,DateTime 休息一个月?

我遇到了这个问题,并认为我的服务器很疯狂,但是在 Codepad中对其进行测试后,我遇到了相同的结果。在使用 Datetime 尝试处理我的日期戳后,在尝试格式化回字符串后,我最终与原始日期相差一天零一个月?这里发生了什么疯狂的事情?

这是代码

0 投票
1 回答
391 浏览

php - PHP curl 的性能相关问题有哪些

我的客户想要提取实时网页的 html 内容并在他的服务器中制作 html 页面的副本。我正在考虑使用 curl,当我打算使用 curl 时是否存在任何性能问题?会不会占用大量服务器内存。

如果 PHP curl 存在性能问题,那么最好的替代方法是什么?

我打算在用户以表单形式提交 Web URl 时下载该页面。我托管网络的服务器位于 linux 平台中。

先感谢您!

0 投票
1 回答
961 浏览

mongodb - MongoCollection 类的 PHPUnit Mock 创建一个 _PHP_Incomplete_Class 对象

今天回到一个好久没碰的项目。这是一个使用 MongoDB 作为其数据库的 Zend Framework 2 项目。

我决定将 MongoDB 从 (2.0) 更新到最新版本 (2.4) 以及将驱动程序更新到最新版本 (1.4.2?) 已经有一段时间了。

现在,在运行我的 PHPUnit 测试时,由于模拟的MongoCollection类未能通过“ is_a() ”测试,我得到了错误。

新的模拟类不是MongoCollection的一个实例,而是一个_PHP_Incomplete_Class实例。我一直在寻找高低,我找不到任何有同样问题的人。我只能假设PHPUnit不喜欢的MongoDB类发生了一些变化。

检查$collection时,我看到:

有谁知道解决这个问题的方法,还是我需要用自己的MongoCollection模拟/测试类进行测试?