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

PHP · Theory

Print

← All stacks

Theory

7/352

Print

print 'Hello'; also writes to the page. It always returns 1 so it can sit in an expression. Teams still write echo. Know both for MCQs.

Trap — treating print as a function with two arguments like echo $a, $b — print takes one argument.

Exam tip

print 'Hello'; — one argument. echo is more common.

Example

<?php
// Print
$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";
}

Print: scores array, print avg, then high marks. Say the output.

Short notes

  • Defprint outputs one value and returns 1.
  • RulePrefer echo in real code.
  • Trapprint a, b like echo.

Questions

1

Can print take two strings like echo?

7 / 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.