With PHP, there are two basic ways to get output:
echoandechoболонIn this tutorial we use
echoorechoболон
PHP echo and print Statements – PHP -ийн echo and print мэдэгдэл #
echoand
echoболонThe differences are small:
echohas no return value whileechocan take multiple parameters (although such usage is rare) whileechois marginally faster thanЯлгаа нь бага байна:
echoнь буцаах утгагүй байхадechoнь олон параметрийг авч чаддаг (гэхдээ ийм хэрэглээ ховор) болechoнь
The PHP echo Statement #
PHP-ийн echo мэдэгдэл #
The echo statement can be used with or without parentheses: echo or echo(). – echo мэдэгдлийг хаалт эсвэл хаалтгүйгээр ашиглаж болно:echo болон echo().
Display Text
Текст үзүүлэх
The following example shows how to output text with the echo command (notice that the text can contain HTML markup): – Дараах жишээнд echo команд ашиглан текст хэрхэн гаргахыг харуулна. (Текст HTML тэмдэглэгээг агуулж болохыг анхаарна уу)
<?php
echo "<h2>PHP is Fun!</h2>";
echo "Hello world!<br>";
echo "I'm about to learn PHP!<br>";
echo "This ", "string ", "was ", "made ", "with multiple parameters.";
?>
<?php
$txt1 = "Learn PHP";
$txt2 = "Apprentice.mn";
$x = 5;
$y = 4;
echo "<h2>" . $txt1 . "</h2>";
echo "Study PHP at " . $txt2 . "<br>";
echo $x + $y;
?> The PHP print Statement – PHP print мэдэгдэл #
The print statement can be used with or without parentheses: print or print(). – print мэдэгдлийг хаалтанд эсвэл хаалтгүй ашиглаж болно:print болон print().
Display Text
Текст харуулах
The following example shows how to output text with the print command (notice that the text can contain HTML markup): – Дараах жишээнд print командын тусламжтайгаар текстийг хэрхэн гаргахыг харуулна (Текст нь HTML тэмдэглэгээг агуулж болохыг анхаарна уу)
<?php
print "<h2>PHP is Fun!</h2>";
print "Hello world!<br>";
print "I'm about to learn PHP!";
?> <?php
$txt1 = "Learn PHP";
$txt2 = "Apprentice.mn";
$x = 5;
$y = 4;
print "<h2>" . $txt1 . "</h2>";
print "Study PHP at " . $txt2 . "<br>";
print $x + $y;
?>