user4370090
user4370090

Reputation:

getall function in PHP

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
}

}

Upvotes: 0

Views: 1728

Answers (1)

Rizier123
Rizier123

Reputation: 59701

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.

Upvotes: 2

Related Questions