![](/img/trans.png)
[英]PHP Catchable fatal error: Object of class webhook could not be converted to string
[英]PHP - Catchable fatal error: Object of class could not be converted to string
我正在尝试在PHP OOP中进行简单选择:
public function loginUsuario($usuario)
{
try {
$pdo = Database::getConnectionPDO();
$usuario = new Usuario();
$usuario->setUsuario($usuario);
$sql = ' SELECT nombres, apellidos FROM tb_usuario WHERE usuario=:usuario ';
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':usuario', $usuario->getUsuario(), PDO::PARAM_STR);
$stmt->execute();
$rs = $stmt->fetchAll();
echo count($rs);
} catch (Exception $ex) {
throw $ex;
}
}
但是,当我运行该方法时,出现此错误:
Catchable fatal error: Object of class Usuario could not be converted to string in D:\xampp\htdocs\usuarios\core\model\usuarioModel.php on line 20
有什么事吗
对象名$usuario
和变量名$usuario
相同。
更改对象名称即可解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.