Install PHP — PHP Technical Interview Questions & Answers
Install PHP
Install PHP
- Install PHP + a server. College: XAMPP (Apache + PHP + MySQL). Check php -v in a new terminal. Put files in htdocs. URL is localhost, not double-clicking the file.
- php -S localhost:8000 is the built-in server for practice. Still use Apache/Nginx in real hosting.
- Trap: editing files outside htdocs. Trap: port 80 busy so XAMPP Apache won’t start — use 8080.
Technical Interview Tip: XAMPP or php -S. php -v. localhost, not file://.
Code Examples for Install PHP
Install PHP — working example
<?php
// Install PHP
$scores = [80, 90, 70];
$avg = array_sum($scores) / count($scores);
echo "avg=" . number_format($avg, 1) . "\n";
foreach ($scores as $s) {
if ($s >= 80) echo "high: $s\n";
}Install PHP: scores array, print avg, then high marks. Say the output.
How to Explain Install PHP to an Interviewer
How do you run a PHP file locally?
XAMPP htdocs + Apache or php -S localhost:8000