1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| <!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<?php
include "php_serial.class.php";
// Let's start the class
$serial = new phpSerial;
// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
$serial->deviceSet("COM3");
// Then we need to open it
$serial->deviceOpen();
// To write into
$serial->sendMessage("Hello !");
// Or to read from
$read = $serial->readPort();
// If you want to change the configuration, the device must be closed
$serial->deviceClose();
// We can change the baud rate
$serial->confBaudRate(115200);
// etc...
?>
<script>
function myFunction(arg) { // Notre argument est la variable « arg »
// Une fois que l'argument a été passé à la fonction, vous allez le retrouver dans la variable « arg »
alert('Vous avez ' + arg + ' ans.');
}
function prompt2(text, allowCancel) {
if (typeof allowCancel === 'undefined') { // Souvenez-vous de typeof, pour vérifier le type d'une variable
allowCancel = false;
}
// Le code
que l'on ne créera pas =p
}
prompt2('Entrez quelque chose :'); // On exécute la fonction seulement avec le premier argument, pas besoin du deuxième
myFunction(prompt('Quel age avez vous ?'));
</script>
</body>
</html> |