php輸出一個或多個字串函數print()

來源:互聯網
上載者:User

執行個體

輸出一些文本:

<?php print "Hello world!"; ?>

定義和用法

print() 函數輸出一個或多個字串。

注釋:print() 函數實際不是一個函數,所以您不必對它使用括弧。

提示:print() 函數比 echo() 速度稍慢。

文法

print(strings)

參數 描述

strings 必需。發送到輸出的一個或多個字串。

技術細節

傳回值: 總是返回 1。

PHP 版本: 4+

更多執行個體

執行個體 1

輸出字串變數($str)的值:

<?php$str = "Hello world!";print $str;?>

執行個體 2

輸出字串變數($str)的值,包含 HTML 標籤:

<?php$str = "Hello world!";print $str;print "<br>What a nice day!";?>

執行個體 3

串連兩個字串變數:

<?php$str1="Hello world!";$str2="What a nice day!";print $str1 . " " . $str2;?>

執行個體 4

輸出數組的值:

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

執行個體 5

輸出一些文本:

<?phpprint "This textspans multiplelines.";?>

執行個體 6

單引號和雙引號的區別。單引號將輸出變數名稱,而不是值::

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.