php中的print函数
php print函数怎么用?
定义和用法
print() 函数输出一个或多个字符串。
注释:print() 函数实际不是一个函数,所以您不必对它使用括号。
提示:print() 函数比 echo() 稍慢。
语法
print(strings)
参数
strings 必需。发送到输出的一个或多个字符串。
返回值: 始终返回 1。
PHP 版本: 4+
例子 1
输出字符串变量($str)的值:
<?php $str = "I love Shanghai!"; print $str; ?>
输出:
I love Shanghai!
例子 2
输出字符串变量($str)的值,包含 HTML 标签:
<?php $str = "I love Shanghai!"; print $str; print "<br>What a nice day!"; ?>
输出:
I love Shanghai! What a nice day!
例子 3
连接两个字符串变量:
<?php $str1 = "I love Shanghai!"; $str2="What a nice day!"; print $str1 . " " . $str2; ?>
输出:
I love Shanghai! What a nice day!
例子 4
输出数组的值:
<?php
$age=array("Bill"=>"60");
print "Bill Gates is " . $age['Bill'] . " years old.";
?>
输出:
Bill Gates is 60 years old.
例子 5
输出文本:
<?php print "This text spans multiple lines."; ?>
输出:
This text spans multiple lines.
例子 6
单引号和双引号的区别。单引号将输出变量名称,而不是值:
<?php $color = "red"; print "Roses are $color"; print "<br>"; print 'Roses are $color'; ?>
输出:
Roses are red Roses are $color
例子 7
向输出写入文本:
<?php print "I love Shanghai!"; ?>
输出:
I love Shanghai!
php中的print函数的更多相关文章
- 《从零开始学Swift》学习笔记(Day 7)——Swift 2.0中的print函数几种重载形式
原创文章,欢迎转载.转载请注明:关东升的博客 Swift 2.0中的print函数有4种重载形式: l print(_:).输出变量或常量到控制台,并且换行. l print(_:_:).输出 ...
- CentOS 6中MATLAB print函数“所见非所得”bug的解决方案
0 系统配置+软件版本 主机:Dell optiplex 390 MT (i5) 系统+软件:CentOS 6.5 x64, Matlab R2012, R2013 系统+软件:CentOS 6.7 ...
- python 中的 print 函数与 list函数
print() 函数: 传入单个参数时默认回车换行,关键词 end 可以用来避免输出后的回车(换行), 或者以一个不同的字符串结束输出. >>> a, b = 0, 1 >& ...
- python中,print函数的sep和end参数
print函数是我们经常使用的,但是它的sep和end参数或许对很多python使用者相对陌生,他们可以让我们的打印更具有个性化. 先来看下官方解释, sep:分割值与值,默认是一个空格 end:附件 ...
- 【转载】 tf.Print() (------------ tensorflow中的print函数)
原文地址: https://blog.csdn.net/weixin_36670529/article/details/100191674 ------------------------------ ...
- python中的print函数
python3.x中将print由一个声明转变成了一个函数. 官方说法: Converts the print statement to the print() function. print(*ob ...
- 把一下程序中的print()函数改写成
源代码: #include <iostream> using namespace std; void print( int w ) { ; i <= w ; i++ ) { ; j ...
- 为什么print在python3中变成了函数?
转自:http://www.codingpy.com/article/why-print-became-a-function-in-python-3/ 在Python 2中,print是一个语句(st ...
- python中print()函数的“,”与java中System.out.print()函数中的“+”
python中的print()函数和java中的System.out.print()函数都有着打印字符串的功能. python中: print("hello,world!") 输出 ...
随机推荐
- 二、点亮LED
接着上一章,本章来实现控制LED的亮灭操作: 一.驱动框架 #include <linux/fs.h> #include <linux/init.h> /* 定义文件内私有结构 ...
- go实现简单的tcp编程
服务端的代码 package main import ( "fmt" "net" ) func main () { fmt.Println("star ...
- MongoDB部分
- python2.7 编码问题
python 2.7编码问题,着实令人头疼不已,这两天抽闲想真正弄明白.需要弄清楚这个问题,首先需要明白ASCII,Unicode 和 UTF-8之间的关系. 进行对上述几种概念进行描述之前,先进行简 ...
- python __enter__ 与 __exit__的作用,以及与 with 语句的关系(转)
https://blog.csdn.net/xc_zhou/article/details/80810111 python __enter__ 与 __exit__的作用,以及与 with 语句的关系
- Quartz.net任务调度(石英钟定时任务)
好了,现在具体来说一下怎么使用Quartz.net 2.0. 1.到网上下载Quartz.net 2.0,下载完后解压,里面有vs.net2008和vs.net2010两个版本. 2.新建一个空项目, ...
- 在sublime3中运行python文件
1.首先下载Sublime和Python,安装Python环境 注意:如果不想动手亲自配置Python环境安装的时候环境变量,请在安装的界面给Add Python 3.5 To Path前面打上对号. ...
- reference website
reference website cplusplus http://www.cplusplus.com/reference/ cppreference https://en.cppreference ...
- TensorType
- ASE19团队项目 beta阶段 model组 scrum3 记录
本次会议于12月4日,19时30分在微软北京西二号楼sky garden召开,持续20分钟. 与会人员:Jiyan He, Lei Chai, Linfeng Qi, Xueqing Wu, Yuto ...