bhylu.com

Advertisements

PHP Introduction

PHP runs on a server or in a terminal. It can calculate a value, read approved data and produce a response. Begin with a visible result before adding a database or framework.

How it works

A browser receives the output of a PHP program, not its private source file. The command-line interpreter runs the same language without an HTTP request. For a lending desk, the first useful question might be how many tools remain available. Keeping that calculation separate from its eventual web page makes it easier to understand and test. PHP and JavaScript are separate languages even when both participate in one website.

Run it locally

Run this complete source locally with PHP 8.2 or newer. Save it using the filename shown and run the command below. PHP is not currently available in Bhylu’s browser playground. Apache and MySQL are not needed for an ordinary CLI example.

php -l intro.php
php intro.php

Download this source as a local PHP lab file. Keep lab files separate from the Bhylu project and production data.

Example

PHP 8.2+ · intro.php

<?php
declare(strict_types=1);

$available = 14;
$borrowed = 5;
echo "Tools remaining: ", $available - $borrowed, "\n";

Expected result

Tools remaining: 9

The two variables store integer counts. Subtraction happens before echo writes the answer. In a terminal you see one text line; a web response could contain that same text but would also have HTTP headers and a status. Neither a database nor Apache is needed for this first calculation.

Check the official PHP manual for detailed version and API contracts.