PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

PHP · Theory

Install PHP

← All stacks

Theory

3/352

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.

Exam tip

XAMPP or php -S. php -v. localhost, not file://.

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.

Short notes

  • DefPHP + Apache (XAMPP) or php -S.
  • Rulephp -v. Open via localhost.
  • Trapfile:// and wrong folder.

Questions

1

How do you run a PHP file locally?

3 / 352

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.