PHP print() ফাংশন

প্রতিমান

আউটপুটে টেক্সট লিখুন:

<?php
print "I love Shanghai!";
?>

Run Example

সংজ্ঞা ও ব্যবহার

print() ফাংশনটি একটি বা একাধিক স্ট্রিং আউটপুট করে।

মন্তব্য:print() ফাংশনটি একটি ফাংশন নয়, তাই আপনাকে ব্যবহার করতে হবে না ব্র্যাকেট।

Tip:print() function is slower than echo() Slower.

Syntax

print(strings)
Parameters Description
strings Required. Send one or more strings to the output.

Technical Details

Return value: Always returns 1.
PHP Version: 4+

More Examples

Example 1

Output the value of a string variable (str):

<?php
$str = 'I love Shanghai!';
print $str;
?>

Run Example

Example 2

Output the value of a string variable ($str), including HTML tags:

<?php
$str = 'I love Shanghai!';
print $str;
print '<br>What a nice day!';
?>

Run Example

Example 3

Connect two string variables:

<?php
$str1 = 'I love Shanghai!';
$str2='What a nice day!';
print $str1 . ' ' . $str2;
?> 

Run Example

Example 4

Output the value of an array:

<?php
$age=array("Bill"=>"60");
print 'Bill Gates is ' . $age['Bill'] . ' years old.';
?>

Run Example

Example 5

Output text:

<?php
print 'This text'
spans multiple
lines.";
?> 

Run Example

Example 6

Difference between single quotes and double quotes. Single quotes will output the variable name, not the value:

<?php
$color = 'red';
print 'Roses are $color';
print '<br>';
print 'Roses are $color';
?>

Run Example