<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* Vérifie la connexion */
if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
exit();
}
if ($stmt = mysqli_prepare($link, "SELECT Name FROM Country WHERE Name=? OR Code=?")) {
$marker = mysqli_stmt_param_count($stmt);
printf("La requête a %d variables.\n", $marker);
/* Fermeture de la commande */
mysqli_stmt_close($stmt);
}
/* Fermeture de la connexion */
mysqli_close($link);
?>
Les exemples ci-dessus vont afficher :
La requête a 2 variables.