Je souhaite afficher le nom de chaque relais avant l'image on.png ou off.png. J'ai 2 pages:Appelez la fonction php() pour afficher le nom avant chaque icône
switch.php and functions.php
switch.php, affiche des icônes ou désactiver pour chaque relais, lecture de l'état de GPIO. functions.php affiche le nom de chaque relais.
Je ne sais pas comment appeler la fonction comme r $ i(), en switch.php pour afficher quelque chose comme:
relay0<img id='button_0' src='images/off.png' alt='off'/><br>
relay1<img id='button_1' src='images/off.png' alt='off'/>
Il y a mes scripts:
// switch.php
<?php
$status = array(0, 0, 0, 0, 0, 0, 0);
for ($i = 0; $i < count($status); $i++) {
//set the pin's mode to output and read them
system("gpio mode ".$i." out");
exec ("gpio read ".$i, $status[$i], $return);
if ($status[$i][0] == 0) {
echo ("<img id='relay_".$i."' src='images/off.png' alt='off'/><br>");
}
if ($status[$i][0] == 1) {
echo ("<img id='relay_".$i."' src='images/on.png' alt='on'/><br>");
}
}
et
// function.php
<?php
function r0(){
echo "relay0";
}
function r1(){
echo "relay1";
}
function r2(){
echo "relay2";
}
function r3(){
echo "relay3";
}
?>
Nous vous remercions de votre aide.
Merci Marios. Je vais essayer ça. – Chris