Why swear?

Recently started to understand the PLO and was immediately faced with the problem
Fatal error: Uncaught Error: Call to undefined function add_in_db() in E:\OSPanel\domains\tutorial\index.php:7 Stack trace: #0 {main} thrown in E:\OSPanel\domains\tutorial\index.php on line 7

Here is the code index.php
<?php
spl_autoload_register(function($className){
 require_once __DIR__ . '/src/' . $className . '.php';
});

$add = new Project\Model\Task\BD();
var_dump(add_in_db());

Here the class file BD.php
<?php
namespace Project\Model\Task;

class BD{
 public $pdo;
 public function add_in_db($task, $table)
{
 $this->pdo = new PDO('mysql:host=localhost; dbname=listask', 'root', ");
 $query = $pdo->prepare("INSERT INTO $table(task) VALUES(?)");
$query->execute([$task]);
}
 public function delete_from_db($id)
{
 $query = $pdo->prepare("DELETE FROM tasks WHERE id = ? ");
$query->execute([$id]);
}
}

What's the problem? And how to solve it?
April 19th 20 at 12:48
2 answers
April 19th 20 at 12:50
The error means that the constant contains an incorrect operation. Probably talking about PD0. Are you sure you need that constant? Then why did you pass her the result of some computation with the parameters? Maybe it should not be a constant?
a little about I changed the code now to another swears) - Timothy_Towne19 commented on April 19th 20 at 12:53
Responsible, you at least looked at the code, no? Obvious mistake has not seen?

$add = new Project\Model\Task\BD();
var_dump(add_in_db());


UPD: TC, it appears, changed the question. Then I apologize to meet. - Shemar.Marquar commented on April 19th 20 at 12:56
April 19th 20 at 12:52
var_dump($add->add_in_db());
But the error would, in any case, because with this method call will not be transferred to the required parameters, in particular $task, $table
and indeed when all hands, except for null that does not receive, the method returns nothing - Darryl.Shanahan commented on April 19th 20 at 12:55

Find more questions by tags OOPPHP