Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele First Application | Ensimmäinen Tutustuminen
Johdanto PHP:hen

First Application

Let's begin with a classic programming example "Hello World". This program serves as the first step for many in programming, demonstrating the basic principles of the language.

main.php

main.php

123
<?php echo "Hello, World!"; ?>

Code Syntax

Let's break down the syntax of this program in detail:

987006bc-1898-4d5a-beeb-adacfd258ce9 HelliWorld
  • <?php and ?>: these indicate the start and end of PHP code. All PHP instructions must be placed between these tags. This defines that the text within these tags will be interpreted as PHP code;

  • echo: this is a PHP language construct used to output data. In our case, we use echo to display the string "Hello, World!";

  • "Hello, World!": this is the text we are echoing with echo. In PHP, strings can be specified in either single or double quotes. It's important that the closing quote matches the opening one;

  • The semicolon (;): this is used to terminate statements. This is necessary so that the PHP interpreter knows where one command ends and the next begins. Without the semicolon, PHP wouldn't be able to correctly parse the code, leading to syntax errors.

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 2
single

single

First Application

Pyyhkäise näyttääksesi valikon

Let's begin with a classic programming example "Hello World". This program serves as the first step for many in programming, demonstrating the basic principles of the language.

main.php

main.php

123
<?php echo "Hello, World!"; ?>

Code Syntax

Let's break down the syntax of this program in detail:

987006bc-1898-4d5a-beeb-adacfd258ce9 HelliWorld
  • <?php and ?>: these indicate the start and end of PHP code. All PHP instructions must be placed between these tags. This defines that the text within these tags will be interpreted as PHP code;

  • echo: this is a PHP language construct used to output data. In our case, we use echo to display the string "Hello, World!";

  • "Hello, World!": this is the text we are echoing with echo. In PHP, strings can be specified in either single or double quotes. It's important that the closing quote matches the opening one;

  • The semicolon (;): this is used to terminate statements. This is necessary so that the PHP interpreter knows where one command ends and the next begins. Without the semicolon, PHP wouldn't be able to correctly parse the code, leading to syntax errors.

Tehtävä

Pyyhkäise aloittaaksesi koodauksen

Your challenge is to output "Hello, Codefinity!" in the console.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 2
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

some-alt