🚧 „Hello World“ mit Java, PHP und JavaScript

Nachdem HTML, CSS und Formulare behandelt wurden, sollte die Verarbeitung der Eingaben angegangen werden. Vergleichen wir mehre Programmiersprachen dazu:
Ein einfaches „Hello World“ Programm soll neben „Hello World“ auch noch die Parameter des Aufrufs ausgeben.

Hello World mit Java

public class Welt{
  public static void main(String[] args){
    System.out.println("Hallo Welt");
    if(args.length>0){ // Wenn Argumente vorhanden
      System.out.print("Argumente: ");  
      for(int i=0;i<args.length;i++){ // Alle Argumente ausgeben mit Zählschleife
        System.out.print(args[i]+" "); 
      }
      for(String arg : args){ // mit "for each"
        System.out.print(arg+" "); 
      }
      System.out.println();
    }
  }
}
Aufruf mit Parametern
Aufruf mit Parametern

Konsolenausgabe:

Hallo Welt
Argumente: Bla Blub Bla Blub 

ToDo: Wdh. Java Besonderheiten

Hello World mit PHP

Voraussetzung: XAMPP, LAMPP,MAMPP installieren

Im Ordner htdocs HalloWelt/hallowelt.php Datei anlegen:

<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hallo Welt</title>
</head>
<body>
   <h1>Hallo Welt PHP</h1>
    <?php
      foreach($_GET as $k => $v){
        print('<b>Feldname: </b>' . $k . ', <b>Inhalt: </b>' . $v . "<br/>\n");
        //echo "<b>Feldname: </b> $k, <b>Inhalt: </b>$v<br/>\n";  
      } 
      phpInfo();
    ?>
</body>
</html>

Aufruf mit http://127.0.0.1/HalloWelt/hallowelt.php?Bla=Blub&prima=Test

Hello World mit Javascript

Synopsis: https://wiki.selfhtml.org/wiki/JavaScript/Tutorials/Einstieg

<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hallo Welt</title>
</head>
<body>
   <h1>Hallo Welt Test</h1>
   <script>
     document.write('Hello World <br>');
     document.write("Browser Version:", navigator.appVersion,"<br>");
     const queryString = window.location.search;
     const urlParams = new URLSearchParams(queryString);
     document.write(queryString,"<br>");
     for (const [key, value] of urlParams.entries()) {
       document.write(`${key}: ${value}`,"<br>");
     }
     document.write("<br>Ende");
  </script>
</body>
</html>

Aufruf im Dateisystem durch Doppelklick auf hallowelt.html Datei öffnet Browserfenster mit URL, dann hinten ?Blub=Bla anhängen und Reload.
BSP-URL: file:///Users/omezger/0mezmedia/Webpublish/HelloWorld/HalloWeltJavaScript/hallowelt.html?Blub=Bla
Oder aus XAMPP: http://127.0.0.1/HalloWeltJavaScript/hallowelt.html?Bla=Blub&prima=Test