duankuai6586 2015-03-15 10:08
浏览 435
已采纳

PHP中的getall函数

What is wrong in my class.It;s giving me syntax error, unexpected ',' on my getall function.Is is not possible to send multiple return value? What would be the problem.

class Form
{
private $name;
private $email;
private $pass;
private $rpass;
private $phone;

public static function setname($name)//setting name
{
    $this->name=$name;
}
public static function email($email)//setting email
{
    $this->email=$email;
}
public static function password($pass)//setting password
{
    $this->pass=$pass;
}
public static function repassword($rpass)//password again
{
    $this->rpass=$rpass;
}
public static function phone($phone)
{
    $this->phone=$phone;
}

 public static function getall() //getting all value
{
  $a=$this->name;
  $b=$this->email;
  $c=$this->pass;
  $d=$this->rpass;
  $e=$this->phone;
  return($a,$b,$c,$d,$e);//here is the problem
}

}

  • 写回答

1条回答 默认 最新

  • dqouryz3595 2015-03-15 10:10
    关注

    It seems like you want to return an array, but what you have is invalid syntax it doesn't mean anything.

    So change this:

    return($a,$b,$c,$d,$e);
    

    to this:

    return [$a,$b,$c,$d,$e];
         //^   See here   ^
    

    For more information about arrays see the manual: http://php.net/manual/en/language.types.array.php#language.types.array.syntax

    Also you can't have static functions with $this. Because $this is only accessible in object syntax, but not in the class itself, so I think you want to remove the static keyword from the functions.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器