PHP中的非法字符串偏移错误 [英] Illegal string offset error in PHP

查看:98
本文介绍了PHP中的非法字符串偏移错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个函数从db获取数据

Hi,I use this function to fetch the data from db

$data=userInfo("ramazan@kacmaz.org","123");





这是输出





this is the output

Array 
( 
    [kId] => 1 
    [ad] => Ramazan 
    [email] => ramazan@kacmaz.org 
    [sifre] => 123 
    [resim] =>  
) 
1  





但是我无法使用foreach得到字段值。我得到了未定义的索引



我尝试了什么:





But I cant get field values using foreach.I am getting undefined index

What I have tried:

foreach ($data as $key => $value) {
      echo $value["ad"];

     }

推荐答案

data = userInfo(ramazan@kacmaz.org, 123);
data=userInfo("ramazan@kacmaz.org","123");





这是输出





this is the output

Array 
( 
    [kId] => 1 
    [ad] => Ramazan 
    [email] => ramazan@kacmaz.org 
    [sifre] => 123 
    [resim] =>  
) 
1  





但是我无法使用foreach得到字段值。我得到了未定义的索引



我尝试了什么:





But I cant get field values using foreach.I am getting undefined index

What I have tried:

foreach (


数据为


key =>
key =>


这篇关于PHP中的非法字符串偏移错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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