Answer the question
In order to leave comments, you need to log in
How to make a function in php in modx or something else?
Hello, help me figure out how the functions in php work, or maybe something else is needed here.
There is a code:
if (true) {
$bd_user = $modx->newObject('User');
$bd_user->set('fullname', $_POST['name']);
$bd_user->set('email', $_POST['email']);
$bd_user->save();
} else {
$id = $_SESSION['id'];
$bd_user = $modx->getObject('User',array('id'=>$id));
$bd_user->set('fullname', $_POST['name']);
$bd_user->set('email', $_POST['email']);
$bd_user->save();
}
Fatal error: Cannot redeclare
Answer the question
In order to leave comments, you need to log in
create a snippet, of course
Cannot redeclare says that a function with that name already exists
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question