Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将变量传递到函数外部的最佳实践_Php_Git - Fatal编程技术网

Php 将变量传递到函数外部的最佳实践

Php 将变量传递到函数外部的最佳实践,php,git,Php,Git,我正在使用管理我的gif图像。我想得到gif每一帧的持续时间。目前我正在使用以下脚本: $gifStream = new FileStream("myfile.gif"); $gifDecoder = new Decoder($gifStream); Global $gifDurations; $gifDecoder->decode(function (FrameDecodedEvent $event) { global $gifDurations; $gifDurations[

我正在使用管理我的gif图像。我想得到gif每一帧的持续时间。目前我正在使用以下脚本:

$gifStream = new FileStream("myfile.gif");
$gifDecoder = new Decoder($gifStream);
Global $gifDurations;

$gifDecoder->decode(function (FrameDecodedEvent $event) {
  global $gifDurations;
  $gifDurations[] = $event->decodedFrame->getDuration();
});
脚本工作正常,输出为:

array(3) { [0]=> int(200) [1]=> int(200) [2]=> int(200) }
但我想知道有没有更好的方法来达到同样的效果?我尝试使用
return
,但没有得到结果。或者我只是没有用正确的方式

请让我知道是否有更好的解决方案


还有,我试着用了。它使用起来很简单,但无法获得正确的持续时间。

你是想标记
git
吗?使用
使用(&$a)
放弃全局想法。a
使用
少一些示例:@evolutionxbox哦..是的。对不起,标签弄错了。@lawrencerone谢谢。我要试试这个