PHP print() º¯Êý

ʵÀý

ÏòÊä³öдÈëÎı¾£º

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

ÔËÐÐʵÀý

¶¨ÒåºÍÓ÷¨

print() º¯ÊýÊä³öÒ»¸ö»ò¶à¸ö×Ö·û´®¡£

×¢ÊÍ£ºprint() º¯Êýʵ¼Ê²»ÊÇÒ»¸öº¯Êý£¬ËùÒÔÄú²»±Ø¶ÔËüʹÓÃÀ¨ºÅ¡£

Ìáʾ£ºprint() º¯Êý±È echo() ÉÔÂý¡£

Óï·¨

print(strings)
²ÎÊý ÃèÊö
strings ±ØÐè¡£·¢Ë͵½Êä³öµÄÒ»¸ö»ò¶à¸ö×Ö·û´®¡£

¼¼Êõϸ½Ú

·µ»ØÖµ£º ʼÖÕ·µ»Ø 1¡£
PHP °æ±¾£º 4+

¸ü¶àʵÀý

Àý×Ó 1

Êä³ö×Ö·û´®±äÁ¿£¨$str£©µÄÖµ£º

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

ÔËÐÐʵÀý

Àý×Ó 2

Êä³ö×Ö·û´®±äÁ¿£¨$str£©µÄÖµ£¬°üº¬ HTML ±êÇ©£º

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

ÔËÐÐʵÀý

Àý×Ó 3

Á¬½ÓÁ½¸ö×Ö·û´®±äÁ¿£º

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

ÔËÐÐʵÀý

Àý×Ó 4

Êä³öÊý×éµÄÖµ£º

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

ÔËÐÐʵÀý

Àý×Ó 5

Êä³öÎı¾£º

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

ÔËÐÐʵÀý

Àý×Ó 6

µ¥ÒýºÅºÍË«ÒýºÅµÄÇø±ð¡£µ¥ÒýºÅ½«Êä³ö±äÁ¿Ãû³Æ£¬¶ø²»ÊÇÖµ£º

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

ÔËÐÐʵÀý

VUE