Hello!

BrainTech - software solutions, web design and applications.

Contact

Module 1 – Introduction to Web Development Lesson

Your First PHP Program

Hello World in htdocs

We write the first program in a hello.php file inside the htdocs folder. PHP code must be inside <?php ... ?> tags. We use echo to output text into the HTML stream. Every statement ends with a semicolon. Comments help explain the code's intent to future readers.

Basic syntax

  • Opening tag <?php and closing ?> (closing optional at end of file).
  • echo outputs a string; variables start with the $ sign.
  • Avoid short PHP tags <? – they are not always enabled on servers.

Debugging

If you see source code instead of the result, Apache is not processing PHP – check whether the PHP module is active and the .php extension is correct.

<?php
$ime = "Ana";
$pozdrav = "Zdravo, " . $ime . "!";
echo "<h1>{$pozdrav}</h1>";
echo "<p>Danas je " . date("d.m.Y") . ".</p>";

Working in the local environment

Create the folder htdocs/php-kurs inside XAMPP htdocs. Practice each new topic in a separate file (e.g. prvi-php-program.php) to track your progress easily. Keep Developer Tools (F12) open – the Network and Console tabs speed up learning.

Design Wireframe
High Fidelity Design
Design development
Design development
Design development
Research development