1、不存在所谓正规写法。
返回数组还是对象,完全取决于个人喜好和编程风格
2、数据库函数集中本身就可以以对象方式返回记录(如mysql_fetch_object)
3、php也提供将数组转换为对象的函数

解决方案 »

  1.   

    谢谢xuzuning(唠叨) ,php也提供将数组转换为对象的函数是什么?我在手册里没找到http://www.phpe.net/manual/language.types.array.php
      

  2.   

    我不是从数据库里返回值,而是读文本,所以不能用mysql_fetch_object()。怎么办,谢谢
      

  3.   

    $a=getall();
    foreach ($a as $b){
    each $b['id'];
    each $b['name'];
    }//you should use array just like this.
      

  4.   

    and if function getall is in a class you should call it use //for public static function
    $return_value=ClassName::getall();//for public function
    $object=new ClassName();
    $return_value=$object->getall();still have problem? send mail to me:  [email protected]