有没有一种方法可以使用eclipse在特定点启动和停止Php代码


Is there a way to start and stop Php code at a specific point using eclipse?

我正在开发一个需要2-5分钟才能运行的脚本。我在脚本中大约4分钟后就开始开发功能了,所以在开发时,我必须一次又一次地运行应用程序,才能进入我正在开发的部分,这可能非常耗时。

有没有一种方法可以从我想要的地方开始脚本(保存所有内部数据,如数组和变量),然后逐步完成我正在开发的代码部分?

请告诉我是否有一个好的解决方案,我正在Wamp服务器上运行Eclipse,我相信有人已经想出了一个解决方案。

假设前4分钟生成的变量保持不变,那么您可以尝试以下操作:


第一轮

<?php
// 4 minutes of code later...
file_put_contents('4_minute_snapshot.json', json_encode(get_defined_vars()));
die();
// new functionality testing

后续回合

<?php
$json_unique_identifier = json_decode(file_get_contents('4_minute_snapshot.json'));
foreach($json_unique_identifier as $k=>$v)
{
    $$k = $v; // $$k is not a typo :-)
}
unset($v, $json_unique_identifier);
// new functionality testing

注意,如果您有资源或其他不可json编码的东西,例如类,那么您应该在// new functionality testing部分之前识别它们并手动设置它们。