zoukankan      html  css  js  c++  java
  • echo和print语句

    语言结构

    • echo的语言结构:echo 或 echo()
    • print的语言结构:print 或 Print()
      举个例子
    <?php
    echo "PHP is fun!<br/>";
    echo ("PHP if fun!");
    ?>
    

    结果语言结构


    共同点:输出字符串、变量

    echo

    <?php
    $txt="learn PHP";
    $letter=array("E","B","C");
    echo "<h3>PHP</h3>";
    echo $txt;
    echo "<br/>";
    echo "my letter is {$letter[0]}";
    ?>
    

    结果echo

    print

    <?php
    $txt="PHP is fun";
    $letter=array("P","G","C");
    print "<h3>PHP is fun</h3>";
    print $txt;
    print "<br/>";
    print "my letter is {$letter[0]}";
    ?>
    

    结果print
    补充:

    • echo、print可以输出html代码
    • array()定义数组

    不同点:数量、返回值

    数量:echo可以输出多个字符串;print只能输出一个字符串

    echo

    <?php
    echo "php ","is ","fun!";
    ?>
    

    结果echo

    print

    <?php
    print "php is fun!";
    ?>
    

    结果print


    返回值:echo不会返回什么;print会返回一个数值1

    以一个例子来说明

    <?php
    $txt="back:";
    echo "echo~echo".print $txt;
    ?>
    

    结果print1
    你会发现 先执行了print并将1返回到print处,然后echo进行输出
    .代表串接

  • 相关阅读:
    arrayPointer
    shellAPP
    docker
    程序运行时内存管理
    C++ deepin
    coreOS+Docker新一代企业轻量级Linux
    玩转docker
    古典小说丛书系列软件
    读《追随智慧》(一)
    高速基于echarts的大数据可视化
  • 原文地址:https://www.cnblogs.com/ceiling-/p/14271093.html
Copyright © 2011-2022 走看看