Reputation: 17
<?
function reg_valid_email(){
if (isset($_POST['register_form_email'])) {
global $mysqli;
return $mysqli->real_escape_string($_POST['register_form_email']);
}
}
$email->reg_valid_email();
?>
Trying to set the value of a function, using the return of a function, but I get error -> Call to a member function reg_valid_email() on string. I'm doing this for first time, so I'm doing something wrong, but can't figure out what is it. // $mysqli is my connection to db
Upvotes: 0
Views: 30
Reputation: 340
you can use if ou want to store the function return
$email=eg_valid_email();
if($email!=NULL)
{
Upvotes: 0
Reputation: 3778
The variable $email
must be an object of a class in which the function reg_valid_email
needs to be defined. But since your code snippet has not mentioned any class, just call your function reg_valid_email
like below without the $email
:
reg_valid_email();
Upvotes: 1