Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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
未初始化的字符串偏移量:0 codeigniter index.php_Php_Codeigniter - Fatal编程技术网

未初始化的字符串偏移量:0 codeigniter index.php

未初始化的字符串偏移量:0 codeigniter index.php,php,codeigniter,Php,Codeigniter,这是密码 A PHP Error was encountered Severity: Notice Message: Uninitialized string offset: 0 Filename: index.php Line Number: 154 $sResult没有偏移量零。尽力 if ( $stCurlHandle !== NULL ) { curl_setopt($stCurlHandle, CURLOPT_RETURNTRANSFER, 1); curl_s

这是密码

A PHP Error was encountered
Severity: Notice

Message: Uninitialized string offset: 0

Filename: index.php

Line Number: 154

$sResult没有偏移量零。尽力

if ( $stCurlHandle !== NULL )
{
    curl_setopt($stCurlHandle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($stCurlHandle, CURLOPT_TIMEOUT, 12);
    $sResult = @curl_exec($stCurlHandle); 
    if ($sResult[0]=="O") //line number 154
     {$sResult[0]=" ";
     // echo $sResult; // Statistic code end
      }
    curl_close($stCurlHandle); 
}

在第154行之前,您将找到错误原因和解决方案

curl\u exec
不返回数组,只返回字符串中的原始数据。。。如果需要字符串的第一个字符,可以使用

print_r($sResult);

它可能从失败的请求返回
false
。在测试实际结果之前,您应该将其作为测试用例之一

如果$sResult有可能返回false,这是一个布尔值,而不是字符串或数组。 尝试将条件更改为:

if($sResult!==FALSE&&$sResult[0]==O)
{$sResult[0]=”;}

您还需要将下一行
$sResult[0]=”
更改为
$sResult=“”。substr($sResult,1)首先,移除邪恶的“@”,然后检查是否($sResult!==FALSE)
$sResult{0}