是否有可能使用数组没有初始化它? [英] Is it possible to use an array without initializing it?

查看:167
本文介绍了是否有可能使用数组没有初始化它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到堆栈溢出一些code。它混淆了我很多。我只是不知道某一部分是否丢失或没有。

I have seen some code from Stack Overflow. It confused me a lot. I just don't know whether some part is missing or not.

在code是如下:

$ch = curl_init($captcha_url);
curl_setopt($ch, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie); 
curl_setopt($ch, CURLOPT_FILE, $fp); 

$out2['result'] = curl_exec($ch);
$out2['error']  = curl_error($ch);
$out2['info']   = curl_getinfo($ch);
curl_close($ch);

我知道 $输出2 ['结果'] 在这里分配的,结果是关键, curl_exec($ CH)是价值在这里。但我还没有看到 $ OUT2 声明为数组?

I know $Out2['result'] is assigned here and result is the key and curl_exec($ch) is value here. But i haven't seen $out2 declared as an array ?

这与该code丢失或我们可以运用这样?

Is this missing from this code or can we apply like this ?

推荐答案

在短,

PHP是不是(目前)是明确有关创建变量时声明数据类型 - 不像其他的语言,但我敢肯定,PHP正在改变他们的方式。

PHP isn't (at the moment) that explicit about declaring data types when creating variables - unlike other languages, although I'm sure PHP are changing their ways.

虽然可以做到这一点,它的建议(好习惯),以将其分配值(S)之前声明变量的数据类型。

Although you can do this, it's advised (good practice) to declare the data type of the variable before assigning value(s) to it.

这篇关于是否有可能使用数组没有初始化它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆