dongzhong8691 2014-02-07 16:31
浏览 48
已采纳

是否可以在不初始化的情况下使用数组?

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.

The code is as follows:

$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);

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 ?

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

  • 写回答

2条回答 默认 最新

  • duanaoreng9355 2014-02-07 16:35
    关注

    In short, yes.

    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.

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题